How to fixed Customer Attribute not saving value in admin panel Magento 2?

Sometimes you may face the issue like Value not update/Save for the customer attribute when you have created a customer attribute using Setup Patch Data in Magento 2.

When you check the log files, you don’t see any error log for this issue, its time consuming to trace the issue instead of customer attribute record generated in eav_attribute, customer_eav_attribute and customer_form_attribute table.

Customer Attribute is not saved any value to the database, because the attribute data not stored in 'eav_entity_attribute' table while creating customer attributes using the Patch Data file.

To avoid these issues, you must specify additional parameters while creating the customer attribute.

  • attribute_set_id
  • attribute_group_id

I will just be given an example of the b2b_user customer attribute with a boolean type.

Create a Setup Patch Data file for the User Defined Customer attribute,

You have to specify two additional parameters in the above script class,

attribute_set_id is used to Get the default attribute set identifier for the entity type customer.
attribute_group_id used to Return default Group Id for current Attribute Set.

This snippet of code is the important in the given Patch file,

You must pass the above two-parameter within used_in_forms data array to fixed the issue of the customer attribute value saving.