views:

24

answers:

1

Hello everybody,

I have a collection_select:

f.collection_select(:selected_id, @subcategories, :id, :cat_transl)

which turns into the following tags:

<option value="4">Deutsch</option>
<option value="5">Chinesisch</option>
<option value="6">Spanisch</option>
<option value="10">Mathematik</option>

What I want is to add a attribute to every option

<option value="4" parent="3">Deutsch</option>
<option value="5" parent="3">Chinesisch</option>
<option value="6" parent="3">Spanisch</option>
<option value="10" parent="9">Mathematik</option>

How is this possible?

Thanks Markus

A: 

This is not possible using the built-in Rails helpers, probably because it's not valid HTML. You can see which attributes the option element supports here:

http://www.w3schools.com/TAGS/tag_option.asp

John Topley