简体   繁体   中英

Is it possible to set a class on Zend MultiOptions?

I have a Zend_Form_Element_MultiSelect 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM