Hi, I have a really simple problem with ruby on rails. Using a basic
tutorial and scaffolding I have a form with lines like this:
<p><label for="user_game1">Game 1: <%= Game.find('1').game %></
<br/>
<%= text_field 'user', 'game_1' %></p>
and I want to change it from a text field to a drop down menu with
three hardcoded values ("Home", "Away" and "Draw").
If someone could help me out that'd be great.
Thanks,
Craig
Hi, I have a really simple problem with ruby on rails. Using a basic
tutorial and scaffolding I have a form with lines like this:
<p><label for="user_game1">Game 1: <%= Game.find('1').game %></
><br/>
<%= text_field 'user', 'game_1' %></p>
and I want to change it from a text field to a drop down menu with
three hardcoded values ("Home", "Away" and "Draw").
select 'user', 'game_1', %w(Home Away Draw)
should do the trick.
Fred
Hi, I have a really simple problem with ruby on rails. Using a basic
tutorial and scaffolding I have a form with lines like this:
<p><label for="user_game1">Game 1: <%= Game.find('1').game %></
><br/>
<%= text_field 'user', 'game_1' %></p>
and I want to change it from a text field to a drop down menu with
three hardcoded values ("Home", "Away" and "Draw").
<%= select 'user', 'game_1', %w(Home Away Draw), :include_blank => true %>
You may or may not want include_blank
See
http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000940
If someone could help me out that'd be great.
Thanks,
Craig
--Greg
11175
(-- --)
4
For Static
<%= select_tag "recipro", options_for_select([ "Received", "Sent",
"Go"],
"Received") %>