I've looked at How do I set the HTML options for collection_select in Rails? and I'm sure I'm missing something obvious, but I can't get this to work.
My select currently looks like:
<%= f.collection_select :broadcast_id, broadcasts, :id, :to_s,
:include_blank => 'Broadcast on...' %>
and I've tried including :class => 'prevent_collapse', which does nothing, as well as {:class => 'prevent_collapse'}, which gives me an error.
If anyone can point out how to do this, I'll be super grateful!
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
=>
f.collection_select :broadcast_id, broadcasts, :id, :to_s,
{:include_blank => 'Broadcast on...'}, {:class => 'prevent_collapse'}
And what error do you have?
And does broadcast item has got :to_s
method? It will return class name, as I think.
Is that field :include_blank => {}
, compulsory ? I tried with :include_blank => false
and it worked. I wonder if we can avoid it ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With