views:

10

answers:

1

Hello all,

I'm trying to get some forms out, but I'm having trouble, in that HAML is not ordering the options in my select elements properly.

Here is my echo statement:

=select 'user', @empty_data, {"Less than $40k" => 1, "$40k - $70k" => 2, "$70k - $100k" => 3, "$100k+" => 4, "No Thanks" => 5 }

However, when the HTML gets rendered, the options are not in any discernible order, let alone the order I placed them in. Is there something I'm not doing correctly?

Thank you

A: 

It's because the list of option is a list of list. Not a Hash

=select 'user', @empty_data, [["Less than $40k", 1], ["$40k - $70k",2], ["$70k - $100k",3], ["$100k+",4], ["No Thanks",5]]

See the documentation about this helper :

http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M002302

shingara