开发者

How to add attributes (id for example) to options of Zend_Form_Element_Select?

I need to add custom attributes (id, c开发者_StackOverflow中文版lass) 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜