I have a multicheckbox element like that:
$element = new Zend_Form_Element_MultiCheckbox('infos', array('disableLoadDefaultDecorators' => true));
$element->addDecorator('ViewHelper')
->setRequired(true)
->addMultiOption('value1', 'BLABLABLA')
->addMultiOption('value2', 'BLABLABLA2')
->addValidator('NotEmpty', true);
$element->getValidator('NotEmpty')->setMessage('Pelo menos uma informação é necessária');
$this->addElement($element);
When i render a multicheckbox element, it appears like that:
<p>
<label for="infos-value1">
<input type="checkbox" name="infos[]" id="infos-value1" value="value1">BLABLABLA
</label><br>
<label for="infos-value2">
<input type="checkbox" name="infos[]" id="infos-value2" value="value2">BLABLABLA2
</label><br>
</p>
And i want to add an attribute for only, let’s say, the first input, so the first input would be something like:
<input type="checkbox" name="infos[]" id="infos-value1" value="value1" disabled>BLABLABLA
</label><br>
How do i add the attribute “disabled” to just one of my two inputs?
Simply pass the indexes for the options to disable like so:
$element->setOptions(array('disable' => array('value1', 'value2')));Not sure this is very well documented anyplace. I am hoping to see some improvements with multi-selects in ZF 2.0. Currently they do have their limitations. Specifically setting class or style attributes on individual options. I have had to extend/add alternate element classes and view helpers to get around some of those issues in the past. Easy enough to do if you must.