I have a form page where I am using
$form->addField('name', 'checkboxes', array('label' => 'check', 'name' => 'name[]',
'values' => array(
array('value'=>'1', 'label'=>'1'),
array('value'=>'2', 'label'=>'2'),
array('value'=>'3', 'label'=>'3'),
array('value'=>'4', 'label'=>'4'),
array('value'=>'5', 'label'=>'5'),
)
));
to create a list of checkboxes.
The problem is I can't figure out how to get them to populate when editing. Can anyone tell me how to do this?
I am using the checkboxes type so they display as a list instead of in separate rows in the form. If there is a way to create them as separate fields but all in one row I would love to know how.
$form->addField('name', 'checkboxes', array('label' => 'check', 'name' => 'name[]',
'values' => array(
array('value'=>'1', 'label'=>'1'),
array('value'=>'2', 'label'=>'2'),
array('value'=>'3', 'label'=>'3'),
array('value'=>'4', 'label'=>'4'),
array('value'=>'5', 'label'=>'5'),
),
'value' => array('1', '5'),
// or
// 'checked' => array('1', '5')
));
Then checkboxes with values "1" and "5" will be checked. For more details you can check lib/Varien/Data/Form/Element/Checkboxes.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With