如何向 Zend_Form_Element_Select 的选项添加属性(例如 id)? [英] How to add attributes (id for example) to options of Zend_Form_Element_Select?
本文介绍了如何向 Zend_Form_Element_Select 的选项添加属性(例如 id)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将自定义属性 (id, class)
添加到 Zend_Form_Element_Select
的选项中.
I need to add custom attributes (id, class)
to options of Zend_Form_Element_Select
.
我该怎么做?
推荐答案
您可以在实例化元素时传入一个属性"数组.例如:
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')
));
这篇关于如何向 Zend_Form_Element_Select 的选项添加属性(例如 id)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文