Magento 2.3 – How to Change Order of Customer Account Form Fields

customerformsmagento2

I created the module name "Name_Module", Now I want to change the order (position) to " create customer account form fields ". How could I achieve this functionality?

Also, need to check if the module is enabled then change the order(position).

Thanks in advance.

Best Answer

You will need to override template file of:

module-customer/view/frontend/templates/form/register.phtml

Create a layout file:

CompanyName/ModuleName/view/frontend/layout/customer_account_create.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>                  
        <referenceBlock name="customer_form_register" ifconfig="section/group/enable>
            <action method="setTemplate">
                <argument name="template" xsi:type="string">CompanyName_ModuleName::form/register.phtml</argument>
            </action>
        </referenceBlock>     
    </body> 
</page>

Template File Path:

CompanyName/ModuleName/view/frontend/templates/form/register.phtml