I have a custom module, it has two fields, table_name and table_number and I have added new field like is_reserve to check if table is reserved,

I have added column in table with integer data type, now I need to add a checkbox for this field on admin form:

                     'name' => 'is_reserved',
                     'label' => __('is reserved'),
                     'title' => __('is reserved'),
                     'onclick'   => 'this.value = this.checked ? 1 : 0;',
                     /*'required' => true,*/

I have added this in block file, what else I need to do to get my checkbox working? It will be a great help if someone can give any hint about this.


  • Can you post your answer? – Nitesh Apr 27 '17 at 5:23

Take a look: vendor/magento/module-customer/Block/Adminhtml/Edit/Tab/Newsletter.php:

                'label' => __('Subscribed to Newsletter'),
                'name' => 'subscription',
                'data-form-part' => $this->getData('target_form'),
                'onchange' => 'this.value = this.checked;'

We can follow the same logic.

  • Hey, thanks for your quick reply, I have added like this, checkbox appeared, but it does not save the value in field. any hint? – Anand Dec 28 '16 at 16:14
  • Try to get the param in your controller? for example: $this->getRequest()->getParams(). Need to check the value is in the params. – Khoa TruongDinh Dec 28 '16 at 16:16
  • nope, I am not able to get values of that field in controller. – Anand Dec 28 '16 at 16:23
  • All fields are not in the controller? – Khoa TruongDinh Dec 28 '16 at 16:25
  • I cant understand, i am new to magento, can you please explain? – Anand Dec 28 '16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.