如何在magento自定义模块中设置复选框的值
如何设置 magento 自定义模块中复选框的值?另外,如何将复选框的名称设置为数组中的值?
这是我用来将复选框放入 magento 模块中的代码:
$fieldset->addField($entity_id['colorcode'], 'checkbox', array(
'label' => Mage::helper('selectcolorforimage')->__($entity_id['colorcode']),
'name' =>'assign_color_new[]',
'values' =>$entity_id['colorcode']
));
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 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']
));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
values
(以“s”结尾)用于选择字段:尝试值(单数)抱歉,请尝试以下操作:
假设
$entity
是您正在使用的对象,在$fieldset
声明之后:查看 Mage_Adminhtml_Block_Customer_Edit_Tab_Account(第 142 行)以了解如何核心去做。
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:Check out Mage_Adminhtml_Block_Customer_Edit_Tab_Account (line 142) to see how the core do it.
检查此代码:
将 myname 替换为您所需的字段名称。另外,
getid
是此数组中动态值的代码。Check this code:
Replace myname with your required field name. Also
getid
is your code for dynamic values in this array.