How to Add Custom Field in Magento 2 Registration Form

Posted at: December 18, 2018 12:26 PM

Adding Customer EAV Attribute

Add custom fields or attribute on Magento 2 Registration form. This attribute also will show in add or edit customer form in Magento 2 Admin.

Creating Module

Create Rsgitech_Customer module.

module.xml

Create file module.xml app/code/Rsgitech/Customer/etc/module.xml

registration.php

Create file registration.php app/code/Rsgitech/Customer/registration.php for register the module.

InstallData.php

Customer attributes are created inside of InstallData and UpgradeData scripts. To add new attributes to the database, you must use the \Magento\Eav\Setup\EavSetupFactory class as a dependency injection.

Create file InstallData.php app/code/Rsgitech/Customer/Setup/InstallData.php for creating customer attribute.

additional.phtml

Create view file additional.phtml app/code/Rsgitech/Customer/view/frontend/templates/additional.phtml for show field on customer registration form.

customer_account_create.xml

Create layout file customer_account_create.xml app/code/Rsgitech/Customer/view/frontend/layout/customer_account_create.xml

Run this command

Completed!!


Admin

How to Add Custom Field in Magento 2 Registration Form

Front

How to Add Custom Field in Magento 2 Registration Form
This lesson also available on YouTube
Create Customer Attribute in Magento 2 Create Custom Attribute in Magento 2 Create Custom Field on Magento 2 Registration Form Create Custom Attribute on Magento 2 Registration Form

Please leave comments

24 Comments