ok,
<?php
class Form_MyTest extends Zend_Form
{
public function init()
{
$element = $this->createElement('multiCheckbox', 'subscribers');
$element->setOptions(array('value1' => 'label1', 'value2' => 'label2'));
$this->addElement($element);
}
}
>
<?php
class MyController extends Zend_Controller_Action
{
public function myTestAction()
{
$form = new Form_MyTest();
$this->view->assign('form', $form);
}
}
>
<form action="<?php echo $this->form->getAction(); ?>" method="<?php echo $this->form->getMethod(); ?>">
<table>
<thead>
<tr>
<th>Select</th>
<th>Number</th>
<th>Name</th>
</tr>
</thead>
<?php $values = $this->form->getElement('subscribers')->getValue(); ?>
<?php foreach($this->form->getElement('subscribers')->getMultiOptions() as $key => $value) : ?>
<tr>
<td><input type="checkbox" name="subscribers[]" id="subscribers-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php echo in_array($key, $values) ? 'checked="checked"':''; ?>/></td>
<td><label for="subscribers-<?php echo $key; ?>"><?php echo $key; ?></label></td>
<td><label for="subscribers-<?php echo $key; ?>"><?php echo $value; ?></label></td>
</tr>
<?php endforeach; ?>
</table>
</form>
>
.
:
<?php $values = $this->form->getElement('subscribers')->getValue(); ?>
>
<?php echo in_array($key, $values) ? 'checked="checked"':''; ?>
>
B/C
$element->setOptions(
$element->setMultiOptions(
key = > value, , , . , , , multiCheckbox,
$this->view->assign('more_datums', array('value1' => array('col_1' => 'col_1_val'[, ...])));foreach
$this->more_datums[$key]['col_1']