如何在magento自定义模块中设置复选框的值 [英] How to set value of checkbox in magento custom module
问题描述
如何在magento自定义模块中设置复选框的值?另外,如何将复选框的名称设置为数组中的值?
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?
这是我用来将复选框放置在magento模块中的代码:
Here is the code I use to put the checkbox in a magento module:
$fieldset->addField($entity_id['colorcode'], 'checkbox', array(
'label' => Mage::helper('selectcolorforimage')->__($entity_id['colorcode']),
'name' =>'assign_color_new[]',
'values' =>$entity_id['colorcode']
));
推荐答案
values
(以' s '结尾)用于选择字段:try值(单数)罢工>
对此感到抱歉,请尝试以下操作:
假定$entity
是您正在使用的对象,在$fieldset
声明之后:
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']);
签出 Mage_Adminhtml_Block_Customer_Edit_Tab_Account (第142行),以查看核心如何做到这一点.
Check out Mage_Adminhtml_Block_Customer_Edit_Tab_Account (line 142) to see how the core do it.
这篇关于如何在magento自定义模块中设置复选框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!