Re: How to do collection_select pulldown style="width:200px" ?

Philip Hallstrom
Tue, 19 Dec 2006 18:23:04 -0000

> Here''s an example of the code I''m trying to get
working...
>
> <%= collection_select(''book'',
''book_type_id'', all_book_types, ''id'',
> ''name'', :prompt => "Select Book Type...",
:style => "width:200px" ) %>
>
> I''ve tried a bunch of different permutations but can''t
get the style
> width to even appear in the html output. Putting the style hash in
> braces with or with the "html_options =" explicitly called out
doesn''t
> help. I''ve Googled and looked at the API but can figure this one
out.
>
> Any ideas?

What about this?

<%= collection_select(''book'',
''book_type_id'', all_book_types,
                       ''id'', ''name'',
                       {:prompt => ''Select Book Type..."},
                       {:style => "width:200px"}
                      )

The docs say that last two arguments are both hashes, so if you don''t
encapsulate the :prompt with {}''s then I think ruby is going to
consider
*everything* from that point on to be part of options, not html_options...


-philip