Magento 2 How to Add Additional Field to Customer Registration Page

Hello Guys! 👋

In this blog, we are going to learn how we can add extra fields to the customer registration page.

By default, Magento 2 provides some built-in registration fields like the first name, email, password, and all but what if we want to add custom fields other than Magento fields?

don’t worry !! with the help of this blog, we will learn how we can add a new Pancard Field to the customer registration page.

Step 1 : create customer_account_Create.xml in path :

app\code\Vendor\Extension\view\frontend\layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="form.additional.info">
            <block class="Magento\Framework\View\Element\Template" name="registration_form_additional" template="Vendor_Extension::pannumber.phtml"/>
        </referenceContainer>
    </body>
</page>
Step 2: create  pannumber.phtml in path

app\code\Vendor\Extension\view\frontend\templates

<div class="field pannnumber required">
            <label for="pannumber" class="label">
                <span>PAN Number</span>
            </label>
            <div class="control">
                <input type="text" name="pancard_number" title="PAN Number" id="pancard_number" class="input-text" data-validate="{required:true}" aria-required="true">
            </div>
</div>

Hope! It will help you

Thank you 😊

How useful was this post?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 25

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *