Magento 2 Custom Customer Attribute not Displaying

Magento 2 Custom Customer Attribute not Displaying

September 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2 Custom Customer Attribute not Displaying

Solving Custom Magento 2 Customer Attribute Issues: A Developer’s Perspective

Hello everyone! I recently ran into an issue while working on a Magento 2 project where custom customer attributes weren’t displaying as expected after the installation data setup was applied. Let me walk you through my process of debugging and resolving this common problem.

The Problem at Hand

After implementing the InstallData.php script provided in the question, I noticed two major issues:

  1. No Frontend Change: The custom attribute wasn’t appearing on the customer’s profile page or during the registration process.
  2. Database Update Failure: Despite saving the attribute in the setup script, no changes were reflected in the customer_eav_attribute table.

It seemed like the data was being installed correctly, but the frontend wasn’t updating to reflect these new customer attributes.

Debugging Steps I Took

  1. Verify Data Installation: First, I made sure that the InstallData.php script was being executed during Magento’s setup process by enabling debugging mode and checking the log files (usually located in /var/log).

  2. Check Attribute Set and Group ID: I confirmed that the default attribute set and group IDs were being fetched correctly for the customer entity.

  3. Save Method Usage: I double-checked that the save() method was being called on the attribute object, ensuring it was actually saved to the database.

The Solution

After some investigation, I realized that the issue wasn’t with the data installation process itself, but rather with how Magento handles new attributes after the initial setup. Here’s what I discovered:

  1. Form Configuration: The key lies in properly configuring which forms the attribute should be used in. In the provided script, only two forms are specified: adminhtml_customer and customer_address_edit.

  2. Customer Form Integration: To display the custom attribute on the customer’s profile page or registration form, you need to add it to the customer_account_create and customer_account_edit forms.

I updated the code as follows:

$attribute->setUsedInForms(['adminhtml_customer', 'customer_address_edit', 'customer_account_edit', 'customer_account_create'])
->save();

The Result

After updating the used_in_forms array to include the necessary customer forms and re-running the installation data script, I saw immediate improvements:

  1. Frontend Appearance: The custom attribute now appeared on the “Edit Your Account Information” page under the “Contact Information” section.

  2. Database Reflection: Upon checking the customer_eav_attribute table again, the new attribute record was present with the correct configuration data.

Conclusion

If you’re facing similar issues when working with Magento 2 custom customer attributes, remember to:

  1. Always verify your database after setup scripts are executed.
  2. Properly configure which forms your attributes should appear in using used_in_forms.
  3. Double-check the attribute’s visibility settings (visible = true and system = 0) to ensure it’s visible on the frontend.

By following these best practices, you can avoid common pitfalls that may cause custom customer attributes not to display as expected after initial setup.

Magento 2 Database Customers Errors

Our network