Add a dropdown list as custom field in magento

Add a dropdown list as custom field in magento

July 25, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add a dropdown list as custom field in magento

Extending Magento Customer Fields: Adding Dropdown Options

In this guide, we’ll walk you through adding dropdown lists as custom fields to your Magento customer account forms. This process involves extending the core functionality of Magento to include selectable options for your customers.

Prerequisites

Before beginning, make sure you have:

  • A basic understanding of PHP and XML.
  • Access to your Magento admin panel with sufficient permissions.
  • Backed up your current theme and database.

Step 1: Create Your Custom EAV Attribute

First, we need to create a new EAV (Entity Attribute Value) attribute that will hold our select options. You can do this directly in the Magento admin:

  1. Navigate to System > Configuration > Attributes > Customer.
  2. Click on Add New Attribute at the top right.
  3. Set your desired attribute properties, such as “Code”, “Label”, and “Input Type” (choose Select).
  4. Save and close.

Step 2: Define Your Options

Next, you need to define the options that will appear in your dropdown list. You can do this via XML:

<global>
  <fieldsets>
    <customer_account_create>
      <field name="custom_field">
        <aspect>general</aspect>
        <label translate="true">My Custom Field</label>
        <input type="select"
               source_model="vendor_module/eav_source_custom_field" />
        <sort_order>10</sort_order>
      </field>
    </customer_account_create>
  </fieldsets>
</global>

Notice we’re using a source_model parameter. This tells Magento where to find the list of options for our field.

Step 3: Create Your Options Source Model

Now, let’s create the source model referenced in the XML:

class EavSourceCustomField extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
    public function getAllOptions()
    {
        $options = [
            ['value' => 'option1', 'label' => __('Option 1')],
            ['value' => 'option2', 'label' => __('Option 2')],
            // Add as many options as you need
        ];

        return $options;
    }
}

This model defines your dropdown’s option list. Make sure it extends Magento\Eav\Model\Entity\Attribute\Source\AbstractSource.

Step 4: Implement Your Source Model

To use this custom source, you’ll need to register it in your module:

public function getOptions()
{
    return [
        'custom_field' => [
            'arguments' => [
                'source_model' => \Vendor\Module\Model\EavSourceCustomField::class,
                'position' => 10,
                'sort_order' => 20,
                'group' => 'general',
            ],
        ],
    ];
}

Conclusion

Adding a dropdown field to your Magento customer account is a straightforward process that involves creating an EAV attribute, defining options in XML, and implementing the corresponding source model. This allows you to provide pre-defined choices for your customers while maintaining the flexibility of custom fields.

Remember to follow best practices when developing for Magento:

  • Always create a custom theme or module.
  • Avoid overwriting core files directly.
  • Keep your code clean and well-documented.

For more advanced techniques in extending Magento functionality, consider checking out our in-depth tutorials on Laravel Company.

Database Security Extensions Themes

Our network