Magento Certified Developer GuideCategory: 10. CustomersHow is customer information validated
Manish Prakash Staff asked 2 years ago

If we go to System -> Configuration -> Customer -> Name and Address Option

there we can configure which information is required for customer account creation. There are different options there for setting required, visible, optional setting for customer attributes.
All the system configuration values have backend model “adminhtml/system_config_backend_customer_customer_show_customer”

This is the important code written in that class

protected function _afterSave()
    {
        $result = parent::_afterSave();

        $valueConfig = array(
            ''    => array('is_required' => 0, 'is_visible' => 0),
            'opt' => array('is_required' => 0, 'is_visible' => 1),
            '1'   => array('is_required' => 0, 'is_visible' => 1),
            'req' => array('is_required' => 1, 'is_visible' => 1),
        );

        $value = $this->getValue();
        if (isset($valueConfig[$value])) {
            $data = $valueConfig[$value];
        } else {
            $data = $valueConfig[''];
        }

        if ($this->getScope() == 'websites') {
            $website = Mage::app()->getWebsite($this->getWebsiteCode());
            $dataFieldPrefix = 'scope_';
        } else {
            $website = null;
            $dataFieldPrefix = '';
        }

        foreach ($this->_getAttributeObjects() as $attributeObject) {
            if ($website) {
                $attributeObject->setWebsite($website);
                $attributeObject->load($attributeObject->getId());
            }
            $attributeObject->setData($dataFieldPrefix . 'is_required', $data['is_required']);
            $attributeObject->setData($dataFieldPrefix . 'is_visible',  $data['is_visible']);
            $attributeObject->save();
        }

        return $result;
    }

So this classes basically updates the customer attribute data with ‘is_required’ and ‘is_visible’ attributes in the table “customer_eav_attribute”

We also have another table “customer_form_attribute” table, which basically defined for each form what all attributes are required to be validated.

So both the table “customer_eav_attribute” and “customer_form_attribute” are responsible for customer validation