Magento-Add a field on default Registration form

Magento-Add a field on default Registration form

July 31, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento-Add a field on default Registration form

Adding a Custom Field to Magento Registration Form: A Step-by-Step Guide

As an experienced developer, I’ve encountered this issue several times while working on Magento projects. Adding custom fields to the registration form can be challenging, but it’s definitely achievable with the right approach. Let me guide you through the process using your provided code as a starting point.

Understanding the Current Situation

You have already created the necessary configuration files and setup scripts. The app\etc\modules directory contains the local module declaration file that enables our custom extension. Your config.xml file includes the required components for the new mobile field.

The Entity_Setup.php file defines the default entities, including the ‘mobile’ attribute with relevant details like label, visibility, and sort order. Finally, the installation script (mysql4-install-0.1.0.php) adds this custom attribute to the customer entity and associates it with several forms using the used_in_forms property.

Identifying the Issue

The problem lies in how Magento processes and renders form data. Even though you’ve correctly added the mobile attribute, Magento doesn’t automatically include it in the registration form without additional configuration changes.

Resolving the Problem

To display the custom field on the registration form, we need to modify two key files:

  1. app\code\local\Mydons\Customer\etc\config.xml

    Update the customer_account fieldset as follows:

    <fieldsets>
        <customer_account>
            <mobile>
                <create>1</create>
                <update>1</update>
                <visible>1</visible>
            </mobile>
        </customer_account>
    </fieldsets>
    

    The visible tag ensures that the field is displayed on both creation and update forms.

  2. app\code\local\Mydons\Customer\controllers\AccountController.php

    In this file, locate the _initNewCustomerAccountAction() method. Add your custom field to the form fields array:

    $form = new Varien_Data_Form();
    ... (existing code)
    $form->addField('mobile', 'text', array(
        'label' => Mage::helper('customer')->__('Mobile'),
        'name'  => 'mobile',
        'required' => true,
        'class' => 'input-text'
    ));
    

Testing the Changes

After making these modifications, clear your cache and refresh the registration page. You should now see the mobile field displayed, ready for user input during account creation or update.

It’s important to note that this is a basic example of adding a custom field. For production environments, you would want to encapsulate this logic in a module rather than hardcoding it directly into controller files. This approach promotes better separation of concerns and easier maintenance.

Remember to keep your code organized and follow Magento’s coding standards for optimal performance and compatibility with future updates.

Conclusion

Adding a custom field to the Magento registration form is a common requirement that can be achieved by following these steps:

  1. Define the attribute using config.xml and Entity_Setup.php.
  2. Install the attribute using the setup script.
  3. Configure the fieldset in config.xml for visibility.
  4. Add the field to the form fields array in your controller.

By understanding Magento’s form rendering process, you can effectively extend functionality while keeping your codebase clean and maintainable. If you have any further questions or need assistance with other customizations, feel free to explore our Magento development resources.

Happy coding!

Database Extensions Configuration Orders

Our network