1

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

I have created file in my theme as below.

app/design/frontend/YOUR_PACKAGE/YOUR_THEME/Magento_Customer/layout/customer_account_create.xml

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" 
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_form_register">
            <action method="setShowAddressFields">
                <argument name="show.address.fields" xsi:type="boolean">true</argument>
            </action>
        </referenceBlock>
    </body>
</page>

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

0

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, privacy policy and cookie policy

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