Friday, May 10, 2013

List of Magento Admin Form Fields


Text Field
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$fieldset->addField('title', 'text', array(
    'label'     => $this->__('Title'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'value'     => 'This is text...',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "alert('On Click');",
    'onchange'  => "alert('On Change');",
    'style'     => "border:5px",
    'after_element_html' => '<small>Comment<small>',
    'tabindex'  => 1
));
Text Area
1
2
3
4
5
6
7
8
9
10
11
12
13
$fieldset->addField('textarea', 'textarea', array(
    'label'     => $this->__('TextArea'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'value'     => '',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Password
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$fieldset->addField('password', 'password', array(
    'label'     => $this->__('Password'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'style'     => "",
    'value'     => 'mojojojo',
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Obscure Password
1
2
3
4
5
6
7
8
9
10
11
12
$fieldset->addField('obscure', 'obscure', array(
    'label'     => $this->__('Obscure'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'obscure',
    'value'     => '04021993',
    'onclick'   => "",
    'onchange'  => "",
    'style'     => "",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Radio Button
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$fieldset->addField('radio', 'radio', array(
    'label'     => $this->__('Radio'),
    'name'      => 'title',
    'value'     => '1',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",         
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
$fieldset->addField('radio2', 'radios', array(
    'label'     => $this->__('Radios'),
    'name'      => 'title',
    'values'    => array(
                      array('value'=>'1','label'=>'Radio1'),
                      array('value'=>'2','label'=>'Radio2'),
                      array('value'=>'3','label'=>'Radio3'),
                 ),
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'value'     => '2',
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Checkbox
1
2
3
4
5
6
7
8
9
10
11
$fieldset->addField('checkbox', 'checkbox', array(
    'label'     => $this->__('Checkbox'),
    'name'      => 'Checkbox',
    'checked'   => false,
    'value'     => '1',
    'disabled'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 3
));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$fieldset->addField('checkboxes', 'checkboxes', array(
    'label'     => $this->__('Checkboxes'),
    'name'      => 'Checkbox',
    'value'     => '2',
    'values'    => array(
                      array('value'=>'1','label'=>'Checkbox1'),
                      array('value'=>'2','label'=>'Checkbox2'),
                      array('value'=>'3','label'=>'Checkbox3'),
                 ),
    'onclick'   => "",
    'onchange'  => "",
    'disabled'  => false,
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 4
));
Dropdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$fieldset->addField('select', 'select', array(
    'label'     => $this->__('Select'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'value'     => '1',
    'values'    => array('-1'=>'Please Select','1' => 'Option1', '2' => 'Option2', '3' => 'Option3'),
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Dropdown v2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$fieldset->addField('select2', 'select', array(
    'label'     => $this->__('Select v2'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'value'     => '4',
    'values'    => array(
                          '-1'=>'Please Select..',
                          '1' => array(
                                   'value'=> array(array('value'=>'2' , 'label' => 'Option2') , array('value'=>'3' , 'label' =>'Option3') ),
                                   'label' => 'Size'   
                                 ),
                          '2' => array(
                                   'value'=> array(array('value'=>'4' , 'label' => 'Option4') , array('value'=>'5' , 'label' =>'Option5') ),
                                   'label' => 'Color'  
                                 ),                                         
                     ),
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Multiselect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$fieldset->addField('multiselect2', 'multiselect', array(
    'label'     => $this->__('Select Type2'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'onclick'   => "return false;",
    'onchange'  => "return false;",
    'disabled'  => false,
    'readonly'  => false,
    'value'     => '3',
    'values'    => array(
                          '-1'=> array( 'label' => 'Please Select..', 'value' => '-1'),
                          '1' => array(
                                   'value'=> array(array('value'=>'2' , 'label' => 'Option2') , array('value'=>'3' , 'label' =>'Option3') ),
                                   'label' => 'Color'   
                                 ),
                          '2' => array(
                                   'value'=> array(array('value'=>'4' , 'label' => 'Option4') , array('value'=>'5' , 'label' =>'Option5') ),
                                   'label' => 'Size'  
                                 ),                                         
                     ),
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 10
));
Multiline
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$fieldset->addField('multiline', 'multiline', array(
    'label'     => $this->__('Multi Line'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'value'     => 'Hello galaxy!',
    'disabled'  => false,
    'readonly'  => false,
    'onclick'   => "",
    'onchange'  => "",
    'style'     => "border:5px",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 1
));
Label
1
2
3
$fieldset->addField('label', 'label', array(
    'value'     => $this->__('Label Text'),
));
Link
1
2
3
4
5
6
7
$fieldset->addField('link', 'link', array(
    'label'     => $this->__('Link'),
    'style'     => "",
    'href'      => 'http://www.brymayor.com/',
    'value'     => 'My Blog',
    'after_element_html' => '<small>Comment</small>',
));
Note
1
2
3
$fieldset->addField('note', 'note', array(
    'text'     => $this->__('Hello galaxy!'),
));
Submit Button
1
2
3
4
5
6
7
$fieldset->addField('submit', 'submit', array(
    'label'     => $this->__('Submit'),
    'required'  => true,
    'value'     => 'Submit',
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 15
));
Time
1
2
3
4
5
6
7
8
9
10
11
12
13
$fieldset->addField('time', 'time', array(
    'label'     => $this->__('Time Title'),
    'class'     => 'required-entry',
    'required'  => true,
    'name'      => 'title',
    'value'     => '04,00,00',
    'onclick'   => "",
    'disabled'  => false,
    'readonly'  => false,
    'onchange'  => "",
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 3
));
File Upload
1
2
3
4
5
6
7
8
$fieldset->addField('file', 'file', array(
    'label'     => $this->__('Uploader'),
    'value'     => 'Uploader',
    'disabled'  => false,
    'readonly'  => false,
    'after_element_html' => '<small>Comment</small>',
    'tabindex'  => 5
));
Image Upload
1
2
3
$fieldset->addField('image', 'image', array(
    'value'     => 'http://brymayor.com/wp-content/uploads/2013/02/default-logo.png',
));
Date
1
2
3
4
5
6
7
$fieldset->addField('date', 'date', array(
    'label'     => $this->__('Date'),
    'after_element_html' => '<small>Comment</small>',
    'image'     => $this->getSkinUrl('images/grid-cal.gif'),
    'format'    => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
    'tabindex'  => 2
));

All the different type of form fields available in Magento can be found in lib/Varien/Data/Form/Element.