Magento – How to make state/company field in new customer creation required from admin panel

customercustomer-address

How to make the company field and state field in the address form (in admin panel, Customer->Manage Customer->new Customers) mandatory when a user is created. I tried to find a phtml corresponding to the form, but dint find any.
Also how to make just the js validation for the company and state field?

Best Answer

The customer fields are based on EAV which means an individual field can't be found in the template files but is stored in the database as an attribute.

In this case it's the customer_eav_attribute table. But first you'll need to know the attribute ID. For that check the eav_attribute table, locate your attribute and use the attribute_id value to locate the correct row in the customer_eav_attribute table. Also set is_required to 1 for this attribute in the table.

If you take a look at the customer_eav_attribute table you'll see a couple of columns, for your question the validate_rules column is the important one. It contains a serialized array with the types of validation.

To make a field simply required adding a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;} should be enough.

I haven't tested this so I'd suggest testing it on a development environment first.

Related Topic