Wednesday, February 24, 2010

select class not applied

<span style="font-size:130%;">Hi, previously my code was like this,

I tried much using, html_options, options, but class is not applied for select.

<%= f.select 'difficulty', options_for_select({ "Easy" => "1", "Medium" => "3", "Hard" => "5"}, get_difficulty(@tour).to_s), :class =>'input_text' %>

& not other way i could find, i did by this way & it works fine now

<%= select :tour, :difficulty, { "Easy" => "1", "Medium" => "3", "Hard" => "5"}, {:selected=>get_difficulty(@tour).to_s}, :class=>"input_text" %>

Now class is applied!!!

Any other better way pls tel me,,.</span>

3 comments:

Bob said...

Good catch Srikanth.
Looks like the kludge (bug workaround) is to add even just an empty hash {} argument before options. Seems to work for both FormHelper and FormBuilder (f.)

Bob said...

good catch, even a dummy arg {} will do it in helper or builder (f.)

Bob said...

{} does it also (f.)