How to set value of checkbox in magento custom module

后端 未结 2 676
我寻月下人不归
我寻月下人不归 2020-12-21 02:56

How do I set the value of a checkbox in a magento custom module? Also, how do I set the name of the checkbox to the value in an array?

Here is the code I use to put

相关标签:
2条回答
  • 2020-12-21 03:13

    Check this code:

    $this->addColumn('myname', array(
                                     'type' => 'checkbox',
                                     'name'=> 'myname',
                                     'values' => $this->_getid(),
                                     'align'   => 'center',
                                     'index' => 'entity_id'
                     ));
    

    Replace myname with your required field name. Also getid is your code for dynamic values in this array.

    0 讨论(0)
  • 2020-12-21 03:26

    values (ending with 's') is for a select field: try value (singular)
    sorry about that, try this instead:
    Assuming $entity is the object you're working with, after the $fieldset declaration:

    $entity->setData('assign_color_new[]', $entity_id['colorcode']);
    

    Check out Mage_Adminhtml_Block_Customer_Edit_Tab_Account (line 142) to see how the core do it.

    0 讨论(0)
提交回复
热议问题