我目前有一个多选框,可将房间与其各自的建筑物分组。
一切都很好,除了我想为每个选项添加一个 ID。
我怎样才能做到这一点?
形式
<div class="form-group">
<%= f.grouped_collection_select(:room_ids, Building.order('name ASC'), :rooms, :name, :id, :name, {include_blank: false}, {multiple: true, size: 10, :class => "form-control"}) %>
</div>
HTML
<select multiple="multiple" size="10" class="form-control" name="key[room_ids][]" id="key_room_ids" data-parsley-multiple="key[room_ids][]" data-parsley-id="5221">
<optgroup label="Accounting Library">
###Is their a way to add an ID to this so I can manipulate it with javascript?
<option value="142">105</option>
<option value="143">105A</option>
</optgroup>
<optgroup label="Ahmanson Center">
<option value="721">fad</option>
<option selected="selected" value="144">105B</option>
</optgroup>
</select>