I am writing this question because I am having difficulty setting default values for the _MultiCheckbox element in Zend Framework 1.9.3. I create a Zend_Form_Element_MultiCheckbox with several parameters:
$multiCheckbox = new Zend_Form_Element_MultiCheckbox( 'elId',
array ( 'disableLoadDefaultDecorators' =>true ) );
$multiCheckbox ->setName( 'elId' )
->setLabel('elId')
->setRequired( false )
->setAttrib('class', 'inputtext')
->setDecorators( array( 'ViewHelper' ) )
->setMultiOptions( $options );
where the $ options array is an associative array of 'key' => 'value'. The field is displayed just fine, and I can get all the checked values for this element.
When returning to this page, I need to restore the entire list of parameters from the list again and mark the marked ones. I tried to do it like this:
$multiCheckbox ->setValue( $defaults );
$default - , 'checked_option_field_id' = > true
(, array ('1222' = > true, '1443' = > true)).
, , , setValue().
, "checked_option_field_id",
(, array ('1222', '1443'))
, - NONE .
setDefaults() , , setValue() .
MultiCheckbox ( ):
<label for="elId-1222"><input type="checkbox" name="elId[]" id="elId-1222" value="1222" checked="checked" class="inputtext">BoRoom </label><br />
<label for="elId-1443"><input type="checkbox" name="elId[]" id="elId-1443" value="1443" checked="checked" class="inputtext">BoRoom Eng2 </label><br/>
elId []. .
formDefaults() , setDefault() setValue(). , multicheckbox elId ( ) , .
, , multicheckbox.