🔥 Just Launched! Werra Premium Template for HyväSee it in Action

Fix: Magento 2 Registration Form Not Showing State Dropdown

By Sanjay JethvaUpdated on Jan 02, 2025 3 min read

Hey Devs!

Are you facing the Magento 2 state/province dropdown not loading issue? Follow me till the end of this post to learn how to solve it.

We love Magento for its extensive customizability and flexibility, thanks to its open-source nature. But quite often, it contains unexpected bugs like missing state/province field Magento 2 registration form. Generally, the state/province is a mandatory field in Magento 2 customer registration and this type of issue can hold the checkouts/account creations.

Therefore, it is recommended to fix the “address from state/province dropdown not showing on Magento 2” issue asap!

Why Magento 2 Registration Form is Not Showing State Dropdown?

The missing state/province field Magento 2 registration issue can be because of missing configuration in theme or module. The issue generally occurs when the default configuration settings are overridden by customizations.

How to Fix State/Province Field Missing on Magento 2 Registration Form?

Follow the steps mentioned below to solve the “Address form state/province dropdown missing” issue in Magento 2:

First, create a new register.phtml file to override the default one. (You can skip this step if you already have one.)

  • Go to [root]/vendor/magento/module-customer/view/frontend/templates/form/ directory.
  • Copy the register.phtml file.
  • Place the file inside your theme directory: for e.g., [root]/app/design/frontend/<vendor_name>/<template_name>/Magento_Customer/templates/form/

In the overridden register.phtml file, locate the JavaScript object responsible for initializing the region updater component.

You will need to replace the lines responsible for passing the regionJson, defaultRegion, and countriesWithOptionalZip to the JavaScript component.

Replace the following lines:

"regionJson": {$regionJson},
"defaultRegion": "{$regionId}",
"countriesWithOptionalZip": {$countriesWithOptionalZip}

with

"regionJson": <?= $regionJson ?>,
"defaultRegion": <?= $regionId ?>,
"countriesWithOptionalZip": <?= $countriesWithOptionalZip ?>

Now, the variables will be correctly echoed and not escaped, fixing the “State/province dropdown not showing on new account creation page” issue in Magento 2.

Once you’re done modifying the code, flush Magento 2 cache using the following command:

php bin/magento cache:flush

That’s it! The “Magento 2 Registration Form Not Showing State Dropdown” will be solved!

Please feel free to comment down if you’ve any doubts or queries. Thanks for reading.

Magento 2 B2B Registration Form

A separate form that collects additional details absent in default Magento 2 form.

Get Extension
Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.