Custom field to Magento registration form can be added by adding custom block to the container form_additional_info to handle customer_account_create with this custom field. Example customer_account_create.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="form_additional_info"> <block name="customer.register.additional.field" class="Web4pro\Customer\Block\Additional" template="Web4pro_Customer::additional.phtml"/> </referenceContainer> </body> </page>
After field is added, code for storing customer’s input should be implemented. It’s possible to with observer on event customer_register_success or by adding attribute to customer entity and adding it to customer_account_create form. If attribute value should be shown on customer edit form in admin, it should be also added to adminhtml_customer. Also field with attribute code should be added to view/adminhtml/ui_component/customer_form.xml in this case.