Magento Certified Developer GuideCategory: 6. AdminhtmlDescribe the concept of Form elements, and list system elements implemented in Magento
Manish Prakash Staff asked 5 years ago

Form elements are basically individual input types in forms like text field, dropdown, etc

The way to add form elements is

$fieldset->addField('code', 'text',
            array(
                'name'      => 'code',
                'label'     => Mage::helper('tax')->__('Name'),
                'class'     => 'required-entry',
                'required'  => true,
            )
        );

$fieldset->addField('calculate_subtotal', 'checkbox',
            array(
                'name'      => 'calculate_subtotal',
                'label'     => Mage::helper('tax')->__('Calculate off subtotal only'),
                'onclick'   => 'this.value = this.checked ? 1 : 0;',
                'checked'   => $model->getCalculateSubtotal()
            )
        );

There are many default form elements provided by magento all are in folder lib/Varien/Data/Form/Element/ few examples being
Varien_Data_Form_Element_Button
Varien_Data_Form_Element_Date
Varien_Data_Form_Element_File