Magento attribute’s attribute frontend_class

Magento EAV framework is very promising, but not easy to understand. When the code is mixed with typos, it becomes even more confusing.

Mage_Catalog_Model_Resource_Eav_Mysql4_Setup provides a template for setting up an attribute.

'name' => array(
'type'              => 'varchar',
'backend'           => '',
'frontend'          => '',
'label'             => 'Name',
'input'             => 'text',
'class'             => '',
'source'            => '',
'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible'           => true,
'required'          => true,
'user_defined'      => false,
'default'           => '',
'searchable'        => false,
'filterable'        => false,
'comparable'        => false,
'visible_on_front'  => false,
'unique'            => false,

However, ‘class’ is wrong. It should be ‘frontend_class’. It refers to DOM class attribute assigned to this entity attribute output html. It can be used for value validation before submission. The possible classes can be found in js/prototype/validation.js. But frontend_class can be set anything you like for css styling or other purposes.

Leave a comment

Your email address will not be published. Required fields are marked *