Magento2: State/Province field doesn't show as required on the add new address page.

Created on 27 Jun 2016  路  15Comments  路  Source: magento/magento2

Steps to reproduce

  1. Install Magento 2 ee/ce through composer.
  2. Set the default Locale as English (United Kingdom) in the backend at Stores > Setting Configuration > General > General > Locale Options > Locale.
  3. Set State as required for the United Kingdom in the backend at Stores > Setting Configuration > General > General > Country Options > State Options > State is Required for.
  4. Create an account in the front-end.
  5. Navigate to My Account > Address Book > Add new address.
  6. Don't fill any fields, just make sure that the country selected in United Kingdom.
  7. Click the save Address Button

Expected result

  1. After selecting the United Kingdom as the country, I'd expect a red star to be added next to the State/Province label as this is a required field for the UK.
  2. After clicking the Save address button, the validation for the State/Province field would fail with a message stating : This is a required field. This is happening.

Actual result

  1. After selecting the UK as the country, the red star is not added next to the label of the state/province filed to indicate that the field is required for the UK. However when you try to save the address without having filled out the state/province field, the validation fails, letting you know that the field is required.

Observations
I have observed that this behaviour only happens when there is no values for the UK state/provinces in the database. This works for the US, I think because the US has predefined states stored in the database and when you select the US as the country, Magento changes the State/Province filed to be a select field and adds the red star next to its label.

Screenshots

  1. Working for the US, the red star is placed next to the State/Province label indicating its a required field
    screen shot 2016-06-27 at 10 01 27

2.Upon changing the country to the UK, the red star disappears, indicating the State/Province field is optional.
screen shot 2016-06-27 at 10 01 39

  1. However if we try to save the address without having filled out the State/Province field, the validation for this field doesn't pass as this is configured to be a required field for the UK.
    screen shot 2016-06-27 at 10 01 45
Customer Ready for Work bug report

Most helpful comment

Magento 2.1.4 (updated from 2.0.8), problem still present.

Steps to reproduce:

  1. Set "Default Country": Italy
  2. Set "State is Required for": Italy
  3. Add products to cart
  4. Go to checkout (checkout only for registered users)
  5. Click on CREATE ACCOUNT, fill required fields
  6. Go on with checkout: State/Province field is not required

Screenshot
province-bug

If you go on without filling state/province, it's impossible to complete the order:

  1. fill required fields, leaving state/province empty
  2. choose payment method (bank payment in my case)
  3. place order: "An error occurred on the server. Please try to place the order again."

Screenshot
province-bug-2
Error message is the same of this one: https://github.com/magento/magento2/issues/6929

If I go back to shipping details and I fill state/province field (which is not required) and I go on, order can be completed.

I need an urgent workaround because my customer website is stuck. Setting state/province as required seems enough to solve this bug.

All 15 comments

Hi @dcabrejasazagra , thanks for reporting this issue. I've created internal ticket MAGETWO-54785.

Thanks,
Anton.

+1 is there a work around for this for the time being?

General > Country Options > State Options > Allow to Choose State if It is Optional for Country
It doesn't work too.

This issue has been delivered to 2.1.3, 2.0.10 as well as 2.2.0

Magento 2.1.4 (updated from 2.0.8), problem still present.

Steps to reproduce:

  1. Set "Default Country": Italy
  2. Set "State is Required for": Italy
  3. Add products to cart
  4. Go to checkout (checkout only for registered users)
  5. Click on CREATE ACCOUNT, fill required fields
  6. Go on with checkout: State/Province field is not required

Screenshot
province-bug

If you go on without filling state/province, it's impossible to complete the order:

  1. fill required fields, leaving state/province empty
  2. choose payment method (bank payment in my case)
  3. place order: "An error occurred on the server. Please try to place the order again."

Screenshot
province-bug-2
Error message is the same of this one: https://github.com/magento/magento2/issues/6929

If I go back to shipping details and I fill state/province field (which is not required) and I go on, order can be completed.

I need an urgent workaround because my customer website is stuck. Setting state/province as required seems enough to solve this bug.

same problem here on Mage 2.1.2 - pretty urgent as well.

adding 'required' property to field using jQuery does not work..
$("[name='region']").prop("required", true);

Yeah same problem here with my e-commerce store in Magneto 2.1.4 (fresh install)

I have specified "State" field as mandatory for my Country, but during checkout the customer is able to add address without the State as it is not shown as required in the address form (however, when customer has registered account and goes to add a new address from account settings, then 'State' is shown as required - go figure !!)

During checkout it gives an "Error occurred on the server" error. When the State is provided in address the checkout goes thru.

This basic issue needs to be fixed ASAP .. losing sales because of this ! Customer obviously does not know issue and abandons the transaction. Why is specifying "State" as mandatory not making it a required field in ALL the various address forms for customers Magento ??

still faceing same problm in magento 2.1.7 this error should solvee :/

Facing the same problem in 2.1.6 version. Error whenever the payment method is paypal.

i'm faceing this issue also :(

@vphat28 you can add this modul into ur site and add your state name then will be solve your problm
https://github.com/php-cuong/magento2-regions-manager

Still in 2.1.8....

HI, facing same problem: on some 2.1.7 installations.

Any suggestions on how to overcome?

thanks everyone

I'm having the same issue when selecting UK as the country.
I'm using Magento version 2.2.2

i'm faceing this issue also :(. any one have solution pls helps us

Was this page helpful?
0 / 5 - 0 ratings