I want to show Address fields in Registration form of Magento 2.4.0

I have created file in my theme as below.


I have set the action method called setShowAddressFields like true by adding below code.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        <referenceBlock name="customer_form_register">
            <action method="setShowAddressFields">
                <argument name="show.address.fields" xsi:type="boolean">true</argument>

I can see address fields after adding this in the layout file, but I could not see state drop-down. I have attached a screenshot of registration form.

enter image description here

2 Answers 2


Create a copy of


on your template:


And replace lines 338-340

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

with these

"regionJson": <?= /* @noEscape */ $regionJson ?>,
"defaultRegion": "<?= /* @noEscape */ $regionId ?>",
"countriesWithOptionalZip": <?= /* @noEscape */ $countriesWithOptionalZip ?>

flush cache.


The state dropdown looks broken in register.phtml. Create a module, or override it in your theme.

Line 328, change it to echo the variables:

<script type="text/x-magento-init">
    "#country": {
        "regionUpdater": {
            "optionalRegionAllowed": <?= /* @noEscape */ $displayAll ? 'true' : 'false' ?>,
            "regionListId": "#region_id",
            "regionInputId": "#region",
            "postcodeId": "#zip",
            "form": "#form-validate",
            "regionJson": <?= $regionJson ?>,
            "defaultRegion": <?= $regionId ?>,
            "countriesWithOptionalZip": <?= $countriesWithOptionalZip ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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