How to add Checkbox field in Form:

Open app/code/local/Namespace/CustomModuleName/Block/Adminhtml/ CustomModuleName /Edit/Tab/Form.php and add the below code.

$fieldset->addField('checkbox_name', 'checkbox', array(        
          'name'      => ' checkbox_name ',        
          'onclick' => 'this.value = this.checked ? 1 : 0;',            
          'tabindex' => 1  
        ));

How to re-populate the checkbox on Edit page:

Just add the extra line in ablove code like below:

$fieldset->addField('checkbox_name', 'checkbox', array(        
          'name'      => ' checkbox_name ',        
          'onclick' => 'this.value = this.checked ? 1 : 0;',            
          'tabindex' => 1  
        ))->setIsChecked($model->getCheckboxName());

Categories: Magento

1 Comment

Rathna Kumar · August 13, 2015 at 11:30 am

we are using payu in our “MAGENTO” site :

payu is “payment method” in india as like paypal.

It’s really strange that payu official code did’t work well

after customer buy the product, than he went to “checkout” page ,

he click on “place order” button , after that it will redirect to “payu site”

he did’t paid money but he can close the payu site without paying, but than also we will recieve the “order”.

we don’t want this to be happen . in magento admin panel, we should get “order” only after customer paid the money in payu.

please help me to find solution.

Leave a Reply

Avatar placeholder

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