Is it possible to set a class on Zend MultiOptions?
I have a Zend_Form_Element_M开发者_运维知识库ultiSelect element. I would like the output to be something like this:
<select id="users" multiple="multiple" name="users[]">
<option value="1" class="role-1">User 1</option>
<option value="2" class="role-1">User 2</option>
<option value="3" class="role-2">User 3</option>
</select>
Is there a way to set class attributes on specific options? I haven't been able to come across anything that would let me do this yet.
Edit: looking at Zend/View/Helper/FormSelect::_build, it doesn't look like there is an automatic way to assign the class. I suppose the only way would be to build the options myself in the view template.
I have no idea if this is possible using decorators but if its not. There is nothing in the world stoping you from creating your own FormSelect functions (overriding) and make it do what you want.
精彩评论