hi
I am facing the following issue:
I have the following dropdown, in the new view
select_tag "experience[]", options_for_select([[less_than_1_year,
[0,1]],[between_1_and_3_years, [1,3]],[between_3_and_5_years,
[3,5]],[between_5_and_7_years,[5,7]], [between_7_and_10_years,[7,10]],
[above_10_years,[10,50]]])
The selected value of the user is not getting reflected in the Edit view
of the entry.
I am using the Form_partial.
Edit View:
<% form_for(@defaultrate) do |f| %>
<%= render :partial =>"form", :locals => { :f => f,
:button =>
"Update" } %>
<% end %>
New view:
<% form_for(@defaultrate) do |f| %>
<%= render :partial =>"form", :locals => { :f => f,
:button =>
"Create" } %>
<% end %>
Please let me know what changes has to be made in controller and view to
reflect the selected value during Edit.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Jul-26 14:01 UTC
Re: Dropdown selected value not reflecting in edit view
You must tell options_for_select which one has to be marked selected That''s the 2nd parameter. options_for_select(container, selected = nil) for example: options_for_select([ "VISA", "MasterCard" ], "MasterCard") would set MasterCard as selected. So you just store the returned params[:experience] somewhere and use that value when redisplaying the select --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---