Reputation: 1539
I'm trying to populate a formtastic select menu using an Array.
PAYMENT_METHODS = %w[creditcard check money-order cash western-union]
<%= f.input :payment_methods, :as=>:select, :collection => User::PAYMENT_METHODS%>
It works but, this is how it appear now.
<select>
<option value="creditcard">creditcard</option>
<option value="western-union">western-union</option>
</select>
Instead I want it to look like:
<select>
<option value="creditcard">Credit Card</option>
<option value="western-union">Western Union</option>
</select>
How can I get this to work?
Upvotes: 0
Views: 611
Reputation: 5733
I wasn't able to test it, but I think you can do it this way.
%w[Credit\ Card Check Money \Order Cash Western\ Union]
From the Programming Ruby docs.
Updated:
After reading back through the select examples on the formtastic Github page, I believe you can do this. As before, it is untested.
<%= f.input :payment_methods, :as=>:select, :collection => { "Credit Card" => "creditcard", "Check" => "check", "Money Order" => "money-order", "Cash" => "cash" "Western Union" => "western-union" >
Upvotes: 1