mipetala Posted April 11, 2011 Share Posted April 11, 2011 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? Link to comment https://forums.phpfreaks.com/topic/233339-multiple-checkbox-some-options-checked-by-default/ Share on other sites More sharing options...
mipetala Posted April 12, 2011 Author Share Posted April 12, 2011 It can't be only me who is having this problem. Any idea? nothing? nada? Link to comment https://forums.phpfreaks.com/topic/233339-multiple-checkbox-some-options-checked-by-default/#findComment-1200392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.