0

I want to add country-state functionality to the customer registration form and how to save it

enter image description here

2
  • There already is the country and the state (according to the selected country) on the customer address. Are you sure you need to duplicate this fields on the customer entity ?
    – Cladiuss
    Jun 2, 2023 at 7:17
  • yes, but in frontend side Jun 2, 2023 at 8:01

1 Answer 1

0

Add below code in your customer_account_create.xml file. This Will add all Address Fields in Registration Form in frontend only

<?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">
            <arguments>
                <argument name="show_address_fields" xsi:type="boolean">true</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
5
  • then how to get this value as a customer attribute for add field in customer account information in admin side? Jun 5, 2023 at 9:05
  • I want to add functionality for a country region in the customer account information section Jun 5, 2023 at 9:07
  • You can't access this value as a customer attribute. You have to access these values as simply Magento did for accessing address values. Jun 6, 2023 at 7:48
  • how to change the sort order of address field Aug 7, 2023 at 6:44
  • using XML file without overriding phtml file is possible? Aug 7, 2023 at 6:46

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.