I need to create State and Country attribute for customer registration and Admin.

How can I Achieving State and Country field functionality in Admin under customer Account Information


State and country should already be listed under Customers -> {Any Customer} -> Addresses in the Admin panel.

On the registration form however, I have noticed Magento has no setting to enable address form on the customer registration page. In vendor/magento/module-customer/view/frontend/templates/form/register.phtml on line 45, you can see there is an if statement wrapped around your address form.

<?php if ($block->getShowAddressFields()): ?>
    <fieldset class="fieldset address">
        <legend class="legend"><span><?= $block->escapeHtml(__('Address Information')) ?></span></legend><br>
        <input type="hidden" name="create_address" value="1" />
        <input type="hidden" name="default_billing" value="1">
        <input type="hidden" name="default_shipping" value="1">

<?php endif; ?>

Copy this template to your own theme and you can either remove the if statement or set the condition to true.

  • I need them on admin >> customer >>Additional information I have created custom country and state field in front end registration referring to the link magecomp.com/blog/… , I need the functionality on admin, Right now I can see the custom fields but cant implement the functionality when country is selected it list only the state and if no option is there text field shows. – fernandus Mar 12 at 15:00

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.