Set Require image in magento

//At the time of insert image uploaded is reqired
            //While time of Edit the control can be blank
            if(Mage::registry('sample_data')->getData('filename')!=""){
                $fieldset->addField('filename','file', array(
                        'label'     =>Mage::helper('sample/data')->__('Logo'),
                        'required'  =>false,
                        'name'      =>'filename',
                        'after_element_html'=>Mage::registry('sample_data')->getData('filename')!=""?'<span class="hint"><img src="'.Mage::getBaseUrl('media')."sample/".Mage::registry('sample_data')->getData('filename').'" width="25" height="25" name="sample_image" style="vertical-align: middle;" /></span>':'',
                    ));
            }else{
                $fieldset->addField('filename','file', array(
                        'label'     =>Mage::helper('sample/data')->__('Logo'),
                        'class'     =>'required-entry',
                        'required'  =>true,
                        'name'      =>'filename',
                        'after_element_html'=>Mage::registry('sample_data')->getData('filename')!=""?'<span class="hint"><img src="'.Mage::getBaseUrl('media')."sample/".Mage::registry('sample_data')->getData('filename').'" width="25" height="25" name="sample_image" style="vertical-align: middle;" /></span>':'',
                    ));

http://tny.cz/6c6bc2df

Magento system settings overview

From time to time  Magento developers face with a need to add settings for their extensions. As it’s hard to remember all necessary details for each setting, so we would like to share our snippets which contain xml code of the most recent settings used in Magento admin. First of all, we would recommend you always place everything, that refers to Magento system settings, in the system.xml file, since it’s the main and the only role of this file. If you need to create your own tab in the admin system settings, you should simply add the following lines to the file:

1
2
3
4
5
6
7
8
<config>
    <tabs>
        <atwix translate="label">
            <label>Atwix Extensions</label>
            <sort_order>150</sort_order>
        </atwix>
    </tabs>   
</config>

As a result, you’ll get the new group (tab) in the admin settings. When you need to complete the procedure of adding settings you should add the following items: section, settings groups and the settings (fields) themselves:

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<config>
    <sections>
        <atwix_shoppingbar translate="label" module="atwix_shoppingbar">
            <class>separator-top</class>
            <label>Shopping Bar</label>
            <tab>atwix</tab>
            <sort_order>130</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <quicksearch>
                    <label>Quick search</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>20</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>0</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <quicksearch_enabled translate="label comment">
                            <label>Enable Quick Search</label>
                            <comment><![CDATA[Enable quick search block]]></comment>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>1</show_in_store>
                        </quicksearch_enabled>
                        <results_count translate="label comment">
                            <label>Results count</label>
                            <comment><![CDATA[Quick search results count (min 1, max 20)]]></comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>1</show_in_store>
                        </results_count>
                    </fields>
                </quicksearch>
            </groups>
        </atwix_shoppingbar>
    </sections>
</config>

Here is an illustration what means each of these terms: sections Next question is how will the different settings in the xml config look like. As you already know, each setting is placed in the <fields> node, then follows the unique setting’s id and finally – setting’s attributes. Here is a small review of the most useful settings: Text field Simple input field for short text values: text_field

1
2
3
4
5
6
7
8
<text_field translate="label">
    <label>Text Field</label>
    <frontend_type>text</frontend_type>
    <sort_order>10</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</text_field>

Textarea Wide input field for long text values: textarea

1
2
3
4
5
6
7
8
<textarea translate="label">
    <label>Textarea</label>
    <frontend_type>textarea</frontend_type>
    <sort_order>20</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</textarea>

Drop down with Yes/No values Drop down menu with the values “Yes” and “No”. Commonly it is used as a flag for enabling/disabling something: dropdown_yesno

1
2
3
4
5
6
7
8
9
<enabled translate="label">
    <label>Enabled</label>
    <frontend_type>select</frontend_type>
    <source_model>adminhtml/system_config_source_yesno</source_model>
    <sort_order>1</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</enabled>

Drop down with Enable/Disable values Almost the same as previous one, but instead of “Yes” and “No” you will get “Enable” and “Disable”: enableddisabled

1
2
3
4
5
6
7
8
9
<active translate="label">
    <label>Enable/Disable</label>
    <frontend_type>select</frontend_type>
    <sort_order>40</sort_order>
    <source_model>adminhtml/system_config_source_enabledisable</source_model>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</active>

Drop down with custom values Drop down with the custom set of values, generated by source model: custom_dropdown

1
2
3
4
5
6
7
8
9
10
<default translate="label">
    <label>Select</label>
    <frontend_type>select</frontend_type>
    <!-- Source model for countries list. For custom list you need to use your own source model -->
    <source_model>adminhtml/system_config_source_country</source_model>
    <sort_order>50</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</default>

Multiselect with custom values Field with the ability to select few items at the same time: multiselect

1
2
3
4
5
6
7
8
9
10
11
<multiselect translate="label">
    <label>Multiselect</label>
    <frontend_type>multiselect</frontend_type>
    <!-- Source model for countries list. For custom list you need to use your own source model -->
    <source_model>adminhtml/system_config_source_country</source_model>
    <sort_order>60</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <can_be_empty>1</can_be_empty>
</multiselect>

File Allows to choose a file for uploading. In this example the file will be saved in var/uploads directory: file

1
2
3
4
5
6
7
8
9
10
<file translate="label comment">
    <label>File</label>
    <frontend_type>file</frontend_type>
    <backend_model>adminhtml/system_config_backend_file</backend_model>
    <upload_dir>var/uploads</upload_dir>
    <sort_order>70</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>0</show_in_website>
    <show_in_store>0</show_in_store>
</file>

Time Is used to create three drop down menus for setting up the hours, minutes and seconds respectively: time

1
2
3
4
5
6
7
8
<time translate="label comment">
    <label>Time</label>
    <frontend_type>time</frontend_type>
    <sort_order>80</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</time>

Editable items list Allows to add/remove text values for the setting: editable_list

1
2
3
4
5
6
7
8
9
10
<addresses>
    <label>Blocked Email Addresses</label>
    <frontend_model>atwix_emailblocker/adminhtml_addresses</frontend_model>
    <backend_model>adminhtml/system_config_backend_serialized</backend_model>
    <sort_order>90</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <can_be_empty>1</can_be_empty>
</addresses>

Heading Is used to entitle some settings inside the group: heading

1
2
3
4
5
6
7
8
<heading translate="label">
    <label>Heading</label>
    <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
    <sort_order>90</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</heading>

Dependent field It can be any field. The main purpose of this one – it’s to hide/show the field depending on the state of  some other field. In the following example the field depends on the field’s enablemethod state. If enablemethod value is 1 – dependent_field will appear and vice versa:

1
2
3
4
5
6
7
8
9
10
11
<dependent_field translate="label">
    <label>Dependent Field</label>
    <frontend_type>textarea</frontend_type>
    <sort_order>100</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <depends>
        <enablemethod>1</enablemethod>
    </depends>
</dependent_field>

There is also one interesting cheat. You are able to use javascript inside of the <comment></comment> node:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<specificerrmsg translate="label">
    <label>Displayed Error Message</label>
    <frontend_type>textarea</frontend_type>
    <comment>
    <![CDATA[
        <script type="text/javascript">
            Event.observe('carriers_flatrate_active', 'change', function() {
                alert('Be careful with this one');
            })
        </script>
    ]]>
    </comment>
    <sort_order>2013</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</specificerrmsg>

It might be useful for changing field’s value depending on different credentials. We would not recommend you to use it very often there, especially for the big javascript code. Moreover, as you might have noticed, there are some attributes like source_model for the custom drop downs or, all the more so, frontend model for editable list which may disappoint a bit. We are going to describe how to operate with these models in our next article, which will see the light in the nearest future. Thank you for reading us 🙂

Magento form validation, text validation, url validation

Most important thing besides assigning class names to form in magento is that little piece of JavaScript below the form. Remember to pass form id into the new VarienForm object.

Basically that’s it. Constructing the form this way, automatically makes your form reuse already existing validation code, the one that the rest of the shop is using.

Below is a full list of validate class and its error message that I found in prototype lib.

    * validate-select

Please select an option.

    * required-entry

This is a required field.

    * validate-number

Please enter a valid number in this field.

    * validate-digits

Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.

    * validate-alpha

Please use letters only (a-z or A-Z) in this field.

    * validate-code

Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.

    * validate-alphanum

Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.

    * validate-street

Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.

    * validate-phoneStrict

Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.

    * validate-phoneLax

Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.

    * validate-fax

Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.

    * validate-date

Please enter a valid date.

    * validate-email

Please enter a valid email address. For example johndoe@domain.com.

    * validate-emailSender

Please use only letters (a-z or A-Z), numbers (0-9) , underscore(_) or spaces in this field.

    * validate-password

Please enter 6 or more characters. Leading or trailing spaces will be ignored.

    * validate-admin-password

Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.

    * validate-cpassword

lease make sure your passwords match.

    * validate-url

Please enter a valid URL. http:// is required

    * validate-clean-url

Please enter a valid URL. For example http://www.example.com or http://www.example.com

    * validate-identifier

Please enter a valid Identifier. For example example-page, example-page.html or anotherlevel/example-page

    * validate-xml-identifier

Please enter a valid XML-identifier. For example something_1, block5, id-4

    * validate-ssn

Please enter a valid social security number. For example 123-45-6789.

    * validate-zip

Please enter a valid zip code. For example 90602 or 90602-1234.

    * validate-date-au

Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.

    * validate-currency-dollar

Please enter a valid $ amount. For example $100.00.

    * validate-one-required

Please select one of the above options.

    * validate-one-required-by-name

Please select one of the options.

    * validate-not-negative-number

Please enter a valid number in this field.

    * validate-state

Please select State/Province.

    * validate-new-password

Please enter 6 or more characters. Leading or trailing spaces will be ignored.

    * validate-greater-than-zero

Please enter a number greater than 0 in this field.

    * validate-zero-or-greater

Please enter a number 0 or greater in this field.

    * validate-cc-number

Please enter a valid credit card number.

    * validate-cc-type

Credit card number doesn\’t match credit card type

    * validate-cc-type-select

Card type doesn\’t match credit card number

    * validate-cc-exp

Incorrect credit card expiration date

    * validate-cc-cvn

Please enter a valid credit card verification number.

    * validate-data

Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.

    * validate-css-length

Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%

    * validate-length

Maximum length exceeded.

Category Dropdown in Admin

Call "toOptionArray" in your grid.php or add in your requirement.

publicfunction toOptionArray($addEmpty =true)
    {
        $options = array();
        foreach($this->load_tree()as $category){
            $options[$category['value']]=  $category['label'];
        }

        return $options;
    }
    
    
    
    publicfunction buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level =0)
    {
        $level++;
    
        $values[$node->getId()]['value']=  $node->getId();
        $values[$node->getId()]['label']= str_repeat("--", $level). $node->getName();
    
        foreach($node->getChildren()as $child)
        {
                $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
        }
    
        return $values;
    }
    
    publicfunction load_tree()
    {
        $store =Mage::app()->getFrontController()->getRequest()->getParam('store',0);
        $parentId = $store ?Mage::app()->getStore($store)->getRootCategoryId():1;  // Current store root category
        
        $tree =Mage::getResourceSingleton('catalog/category_tree')->load();
    
        $root = $tree->getNodeById($parentId);
    
        if($root && $root->getId()==1)
        {
                $root->setName(Mage::helper('catalog')->__('Root'));
        }
    
        $collection =Mage::getModel('catalog/category')->getCollection()
        ->setStoreId($store)
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('is_active');
    
        $tree->addCollectionData($collection,true);
    
        return $this->buildCategoriesMultiselectValues($root, array());
    }

http://www.vuleticd.com/2012/12/30/magento-admin-product-grid-category-filter/

http://www.vuleticd.com/wp-content/uploads/2012/12/Vuleticd_AdminGridCategoryFilter-0.0.0.1.zip

Magento admin form fields

In this tutorial, i will show you all different magento admin form fields we can use in admin forms.

Magento has many different type of field available by default, so lets take a look the syntax of using each of these fields.

if you wan to to validate fields check my magento validation post.

You can add form fileds in form.php in class like YOURPACKAGE_YOURMODULE_Block_Adminhtml_Form_Edit_Tab_Form inside the _prepareForm() function. All the different type of form fields available in magento are located in folder lib\Varien\Data\Form\Element

Text

01 $fieldset->addField('title', 'text', array(
02           'label'     => Mage::helper('core')->__('This is Text Field'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "alert('on click');",
07           'onchange' => "alert('on change');",
08           'style'   => "border:10px",
09           'value'  => 'hello !!',
10           'disabled' => false,
11           'readonly' => true,
12           'after_element_html' => '<small>Comments</small>',
13           'tabindex' => 1
14         ));

 

Time

01 $fieldset->addField('time', 'time', array(
02           'label'     => Mage::helper('core')->__('This is Time Field'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'value'  => '12,04,15',
09           'disabled' => false,
10           'readonly' => false,
11           'after_element_html' => '<small>Comments</small>',
12           'tabindex' => 1
13         ));

 

Textarea

01 $fieldset->addField('textarea', 'textarea', array(
02           'label'     => Mage::helper('core')->__('This is TextArea Field'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'value'  => '<b><b/>',
09           'disabled' => false,
10           'readonly' => false,
11           'after_element_html' => '<small>Comments</small>',
12           'tabindex' => 1
13         ));

 

Submit Button

1 $fieldset->addField('submit', 'submit', array(
2           'label'     => Mage::helper('core')->__('Submit button'),
3           'required'  => true,
4           'value'  => 'Submit',
5           'after_element_html' => '<small>Comments</small>',
6           'tabindex' => 1
7         ));

 

Dropdown / Selectbox

01 $fieldset->addField('select', 'select', array(
02           'label'     => Mage::helper('core')->__('Select'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'value'  => '1',
09           'values' => array('-1'=>'Please Select..','1' => 'Option1','2' => 'Option2', '3' => 'Option3'),
10           'disabled' => false,
11           'readonly' => false,
12           'after_element_html' => '<small>Comments</small>',
13           'tabindex' => 1
14         ));

 

here is another way to add Dropdown or select box

01 $fieldset->addField('select2', 'select', array(
02           'label'     => Mage::helper('core')->__('Select Type2'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'value'  => '4',
09           'values' => array(
10                                 '-1'=>'Please Select..',
11                                 '1' => array(
12                                                 'value'=> array(array('value'=>'2' , 'label' => 'Option2') , array('value'=>'3' , 'label' =>'Option3') ),
13                                                 'label' => 'Size'
14                                            ),
15                                 '2' => array(
16                                                 'value'=> array(array('value'=>'4' , 'label' => 'Option4') , array('value'=>'5' , 'label' =>'Option5') ),
17                                                 'label' => 'Color'
18                                            ),                                        
19
20                            ),
21           'disabled' => false,
22           'readonly' => false,
23           'after_element_html' => '<small>Comments</small>',
24           'tabindex' => 1
25         ));

 

Radio Button

01 $fieldset->addField('radio', 'radio', array(
02           'label'     => Mage::helper('core')->__('Radio'),
03           'name'      => 'title',
04           'onclick' => "",
05           'onchange' => "",
06           'value'  => '1',
07           'disabled' => false,
08           'readonly' => false,
09           'after_element_html' => '<small>Comments</small>',
10           'tabindex' => 1
11         ));

 

here is another way to add  radio button

01 $fieldset->addField('radio2', 'radios', array(
02           'label'     => Mage::helper('core')->__('Radios'),
03           'name'      => 'title',
04           'onclick' => "",
05           'onchange' => "",
06           'value'  => '2',
07           'values' => array(
08                             array('value'=>'1','label'=>'Radio1'),
09                             array('value'=>'2','label'=>'Radio2'),
10                             array('value'=>'3','label'=>'Radio3'),
11                        ),
12           'disabled' => false,
13           'readonly' => false,
14           'after_element_html' => '<small>Comments</small>',
15           'tabindex' => 1
16         ));

 

Password Field

01 $fieldset->addField('password', 'password', array(
02           'label'     => Mage::helper('core')->__('Password'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'style'   => "",
09           'value'  => 'hello !!',
10           'disabled' => false,
11           'readonly' => false,
12           'after_element_html' => '<small>Comments</small>',
13           'tabindex' => 1
14         ));

 

another way to add password field

01 $fieldset->addField('obscure', 'obscure', array(
02           'label'     => Mage::helper('core')->__('Obscure'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'obscure',
06           'onclick' => "",
07           'onchange' => "",
08           'style'   => "",
09           'value'  => '123456789',
10           'after_element_html' => '<small>Comments</small>',
11           'tabindex' => 1
12         ));

 

Note

1 $fieldset->addField('note', 'note', array(
2           'text'     => Mage::helper('core')->__('Text Text'),
3         ));

 

Multiselect

01 $fieldset->addField('multiselect2', 'multiselect', array(
02           'label'     => Mage::helper('core')->__('Select Type2'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "return false;",
07           'onchange' => "return false;",
08           'value'  => '4',
09           'values' => array(
10                                 '-1'=> array( 'label' => 'Please Select..', 'value' => '-1'),
11                                 '1' => array(
12                                                 'value'=> array(array('value'=>'2' , 'label' => 'Option2') , array('value'=>'3' , 'label' =>'Option3') ),
13                                                 'label' => 'Size'
14                                            ),
15                                 '2' => array(
16                                                 'value'=> array(array('value'=>'4' , 'label' => 'Option4') , array('value'=>'5' , 'label' =>'Option5') ),
17                                                 'label' => 'Color'
18                                            ),                                        
19
20                            ),
21           'disabled' => false,
22           'readonly' => false,
23           'after_element_html' => '<small>Comments</small>',
24           'tabindex' => 1
25         ));

 

Multiline

01 $fieldset->addField('multiline', 'multiline', array(
02           'label'     => Mage::helper('core')->__('Multi Line'),
03           'class'     => 'required-entry',
04           'required'  => true,
05           'name'      => 'title',
06           'onclick' => "",
07           'onchange' => "",
08           'style'   => "border:10px",
09           'value'  => 'hello !!',
10           'disabled' => false,
11           'readonly' => true,
12           'after_element_html' => '<small>Comments</small>',
13           'tabindex' => 1
14         ));

 

Link

1 $fieldset->addField('link', 'link', array(
2           'label'     => Mage::helper('fore')->__('Link'),
3           'style'   => "",
4           'href' => 'raisereview.com',
5           'value'  => 'RaiseReview by R Vadgama',
6           'after_element_html' => ''
7         ));

 

Label

1 $fieldset->addField('label', 'label', array(
2           'value'     => Mage::helper('core')->__('Label Text'),
3         ));

 

Image Upload

1 $fieldset->addField('image', 'image', array(
2           'value'     => 'https://bmagento.wordpress.com',
3         ));

 

File Upload

1 $fieldset->addField('file', 'file', array(
2           'label'     => Mage::helper('core')->__('Upload'),
3           'value'  => 'Uplaod',
4           'disabled' => false,
5           'readonly' => true,
6           'after_element_html' => '<small>Comments</small>',
7           'tabindex' => 1
8         ));

 

Date

1 $fieldset->addField('date', 'date', array(
2           'label'     => Mage::helper('core')->__('Date'),
3           'after_element_html' => '<small>Comments</small>',
4           'tabindex' => 1,
5           'image' => $this->getSkinUrl('images/grid-cal.gif'),
6           'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
7         ));

 

Checkbox

01 $fieldset->addField('checkbox', 'checkbox', array(
02           'label'     => Mage::helper('core')->__('Checkbox'),
03           'name'      => 'Checkbox',
04           'checked' => false,
05           'onclick' => "",
06           'onchange' => "",
07           'value'  => '1',
08           'disabled' => false,
09           'after_element_html' => '<small>Comments</small>',
10           'tabindex' => 1
11         ));

 

another way to add checkbox

01 $fieldset->addField('checkboxes', 'checkboxes', array(
02           'label'     => Mage::helper('core')->__('Checkboxs'),
03           'name'      => 'Checkbox',
04           'values' => array(
05                             array('value'=>'1','label'=>'Checkbox1'),
06                             array('value'=>'2','label'=>'Checkbox2'),
07                             array('value'=>'3','label'=>'Checkbox3'),
08                        ),
09           'onclick' => "",
10           'onchange' => "",
11           'value'  => '1',
12           'disabled' => false,

Join two table

// this get table name from config.xml

$tableName = Mage::getSingleton(‘core/resource’)->getTableName(‘bharat_sliders/categories’);
$slides->getSelect()
->join( array(‘sc’=>$tableName),
‘main_table.slider_id = sc.slider_id’, array(‘sc.*’))
->where(‘sc.category_id = ?’, $this->getCategoryId());
return $slides;

Join two table in Magento

Join two table in Magento

$attrubutesdata = Mage::getModel(‘contacts/attrubutes’)->getCollection();
      $this->setCollection($attrubutesdata);
      $this->getCollection()->getSelect()->join(array(‘te’=>’forms_entity’),’main_table.entity_id=te.entity_id’,array(‘entity_name’=>’te.entity_name’));