cancel
Showing results for 
Search instead for 
Did you mean: 

Add Custom Field in customer registration form

Add Custom Field in customer registration form

Hello,

i need to insert a custom field in my customer registration form.

A registration number will be entered within this field.

 

2 checks must be carried out:
1) check that the number is among those loaded in the database
2) verify that it has not already been used

 

I use magento 2.4.5.

 

Do you have any suggestions?

3 REPLIES 3

Re: Add Custom Field in customer registration form

To add a custom field to the customer registration form in Magento 2.4.5 and perform the required checks, follow these steps:

  1. Create a custom module.
  2. Create a custom database table to store registration numbers.
  3. Add the custom field to the registration form using a layout file.
  4. Create a custom validator class to check the registration number against the database.
  5. Configure the validation rules in the di.xml file of your module.
  6. Save the custom field data to the database.
  7. Display appropriate error messages if the registration number fails the checks.
  8. Test the registration form and refine as needed.

For more detailed instructions, consider consulting a Magento developer or referring to the official Magento documentation.

If the issue will be resolved, Click Kudos & Accept as a Solution.

Re: Add Custom Field in customer registration form

how can i Create a custom validator class to check the registration number against the database?  can you give me an example?
thanks for your help

Re: Add Custom Field in customer registration form

To add a custom field to the customer registration form in Magento 2.4.5. Create a new module, define a new attribute for the registration number, modify the form layout to include the field, implement validation checks to ensure the number exists in the database and is unique, display error messages if needed, and save the custom attribute with the customer data. Seek documentation or developer help if necessary.