I need to add custom attributes (id, class)
to options of Zend_Form_Element_Select
.
How can I do that?
I need to add custom attributes (id, class)
to options of Zend_Form_Element_Select
.
How can I do that?
You can pass in an "attribs" array when instantiating the element. For example:
$form->addElement('select', 'type', array(
'label' => 'Label',
'multioptions' => $some_array,
'attribs' => array('class' => 'selector', 'id' => 'whatever')
));
AFAIK it's not possible to add ids to select's options. Option would be implementing your own viewHelper and adding this functionality. But generally it's not possible.