0


i am using mageplaza one step checkout and state field is not showing as required field nor the javascript validation working on that field. I am newbie in Magento 2 i don't know too much about the knockout js.

i tried to found the State field so that i can add the validation and check whether or not it is applied. I found one XML file which contains the code below showing that the validation is already applied but not working in the frontend. Suggest me something.

<item name="component" xsi:type="string">Magento_Ui/js/form/element/region</item>

<item name="config" xsi:type="array">

    <item name="template" xsi:type="string">ui/form/field</item>

    <item name="elementTmpl" xsi:type="string">ui/form/element/select</item>

    <item name="customEntry" xsi:type="string">shippingAddress.region</item>

</item>

<item name="validation" xsi:type="array">

    <item name="required-entry" xsi:type="boolean">true</item>

</item>

<!-- Value of region_id field is filtered by the value of county_id attribute -->

<item name="filterBy" xsi:type="array">

    <item name="target" xsi:type="string"><![CDATA[${ $.provider }:${ $.parentScope }.country_id]]></item>

    <item name="field" xsi:type="string">country_id</item>

</item>

Found this as the issue is in the core files of magento. My version of Magento is 2.1.3 Please let me know if you found any solution.

https://github.com/magento/magento2/pull/10924

0

Magento 2 has a built in feature that allows the user to specify countries for for which state is a required field.

In that feature, you can remove validation for selected countries.

You can find the settings in Admin Panel > Stores > Settings > Configuration > General > General > State options > State is Required for

You have to un-tick the "Use system value" and un-select the countries that you want the state to be validated for.

  • I already checked that and all other settings are looking fine – Rakesh Kumar Nov 14 '18 at 11:28
  • There was issue of the state because states are not mentioned for other countries in table except America that's why state field become optional. If we add states in database of that country then state will become compulsory. – Rakesh Kumar Nov 20 '18 at 6:15
  • I'm glad you found the problem :) – Greg Nov 20 '18 at 9:19
0

There was issue of the state because states are not mentioned for other countries in table except America that's why state field become as textbox and optional. If we add states in database of that country then state will become select element and compulsory for customers.

Up vote Guys If you found it helpful...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.