Hi!
I want to have some elements checked by default depending on the value in database.
My problem is that if one element of the array gets checked then all the other elements become also checked.
For example:
$checkbox = new Zend_Form_Element_MultiCheckbox(self::SELECT, array('Decorators'=>array('ViewHelper', 'Errors', 'Label', array('HtmlTag', array('tag'=>'div', 'class'=>'select_surveillance')))) ) ;
foreach($this->_accountListGroups as $i => $value)
{
if($value->getSurveillance())
{
$checkbox->addMultiOption($i , value->getDisplayName())->setAttrib("checked", "checked");
}
$checkbox->addMultiOption($i , $value->getDisplayName());
}
Although I have just one $value->getSurveillance() == true, I get the following result:
<div class="select_surveillance">
<label for="select-3"><input type="checkbox" name="select[]" id="select-3" value="3" checked="checked" />Customer1 gw140</label><br />
<label for="select-8"><input type="checkbox" name="select[]" id="select-8" value="8" checked="checked" />Customer1 gw70</label><br />
<label for="select-4"><input type="checkbox" name="select[]" id="select-4" value="4" checked="checked" />Customer2 gw140</label><br />
<label for="select-5"><input type="checkbox" name="select[]" id="select-5" value="5" checked="checked" />Customer3 gw140</label>
</div>
Does anyone know another way to check some of my checkboxes?