I need to add Phone field in registration form frontend. It is only added in Contact Information after registration. Any help?

     <?php $block->setShowAddressFields(true); ?>
        <?php if ($block->getShowAddressFields()): ?>
            <fieldset class="fieldset address">
                <!--legend class="legend"><span><?php echo __('Address Information') ?></span></legend><br-->
                <input type="hidden" name="create_address" value="1"/>
                <!--div class="field company">
                    <div class="control">
                        <input placeholder="<?php echo __('Company') ?>" type="text" name="company" id="company" value="<?php echo $block->escapeHtml($block->getFormData()->getCompany()) ?>" title="<?php echo __('Company') ?>"
                               class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('company') ?>" />
                <div class="field telephone">
                    <div class="control">
                        <input placeholder="<?php echo __('Phone number') ?>" type="text" name="telephone" id="telephone" value="<?php echo $block->escapeHtml($block->getFormData()->getTelephone()) ?>" title="<?php echo __('Phone Number') ?>"
                               class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('telephone') ?>" />

                <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
                <input type="hidden" name="street[]" value="USA"/>
                <input type="hidden" name="city" value="USA"/>
                <input type="hidden" name="postcode" value="0000"/>
                <input type="hidden" name="country_id" value="US"/>
                <!--div class="field street required">
                    <div class="control">
                        <input placeholder="<?php echo __('Address') ?>" type="text" name="street[]" value="<?php echo $block->escapeHtml($block->getFormData()->getStreet(0)) ?>"
                               title="<?php echo __('Street Address') ?>" id="street_1"
                               class="input-text <?php echo $_streetValidationClass ?>" />
                        <div class="nested">
                            <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
                            <?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?>
                                <div class="field additional">
                                    <label class="label" for="street_<?php echo $_i ?>"><span><?php echo __('Address') ?></span></label>
                                    <div class="control">
                                        <input type="text" name="street[]" value="<?php echo $block->escapeHtml($block->getFormData()->getStreetLine($_i - 1)) ?>"
                                               title="<?php echo __('Street Address %1', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
                            <?php endfor; ?>
                <!--div class="field required">
                    <div class="control">
                        <input placeholder="<?php echo __('City') ?>" type="text" name="city" value="<?php echo $block->escapeHtml($block->getFormData()->getCity()) ?>" id="city"
                               title="<?php echo __('City') ?>" class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city') ?>"/>
                <!--div class="field region required">
                    <div class="control">
                        <select id="region_id" name="region_id" title="<?php echo __('State/Province') ?>" class="validate-select" style="display:none;">
                            <option value=""><?php echo __('Please select a region, state or province.') ?></option>
                        <input placeholder="<?php echo __('State/Province') ?>" type="text" id="region" name="region" value="<?php echo $block->escapeHtml($block->getRegion()) ?>" title="<?php echo __('State/Province') ?>"
                               class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                <!--div class="field zip required">
                    <div class="control">
                        <input placeholder="<?php echo __('Zip/Postal Code') ?>" type="text" name="postcode" value="<?php echo $block->escapeHtml($block->getFormData()->getPostcode()) ?>" title="<?php echo __('Zip/Postal Code') ?>" id="zip"
                               class="input-text validate-zip-international <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode') ?>">
                <!--div class="field country required">
                    <div class="control"><?php echo $block->getCountryHtmlSelect() ?></div>

                <?php $addressAttributes = $block->getChildBlock('customer_form_address_user_attributes'); ?>
                <?php if ($addressAttributes): ?>
                    <?php $addressAttributes->setEntityType('customer_address'); ?>
                    <?php $addressAttributes->setFieldIdFormat('address:%1$s')->setFieldNameFormat('address[%1$s]'); ?>
                    <?php $block->restoreSessionData($addressAttributes->getMetadataForm(), 'address'); ?>
                    <?php echo $addressAttributes->setShowContainer(false)->toHtml() ?>
                <?php endif; ?>
                <input type="hidden" name="default_billing" value="1">
                <input type="hidden" name="default_shipping" value="1">
        <?php endif; ?>
  • Have you try anything. Commented Apr 30, 2019 at 14:26

2 Answers 2


Add a Phone Number (Telephone) Field in a Customer Register Page

before that, We need to know that telephone number is a part of customer address section.

If we want this (Telephone) field we need to enable address section in Customer Register Page.

But don't want to enable Address section on registration time and want telephone number in Register page then we have to create custom Phone Number (Telephone) field.

So How to added custom field in Customer Register Page, please follow this link

More help please feel free to ask.


Override edit.phtml file using customer_account_edit.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
        <!-- Set Custom Template for Register form -->
        <referenceBlock name="customer_edit">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magento_Customer::form/edit.phtml</argument>
        <!-- End -->

Override form/edit.phtml and Add Your Custom Field

  • 1
    You miss understand me. The field is already there, and you can fill it from Contact Information in my account after registration. I just want to show that field in registration form to be filled. Commented Apr 30, 2019 at 14:35
  • Check updated my answer Commented Apr 30, 2019 at 14:37
  • Sorry, I'm new with magento2. I may need more explanation. in my theme\Magento_Customer\layout\customer_account.xml file, I added your answer code, but it showed error because both <vendor> <Module> tags not closed. I copied edit.phtml in my theme, but no idea how to add my Phone no. field Commented Apr 30, 2019 at 20:49
  • It is how to enable Phone field in Magento Customer Registration Form :) Commented Apr 30, 2019 at 20:59
  • vendor module is your custom module name Commented Apr 30, 2019 at 21:02

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.