Hello, I have a form [using start_form_tag] with a select_tag. I need to populate the values [id and name] from a model. So far all the examples for populating values of select box from database uses form_for and form.collection_select method. Is there a similar way to do that for from_tag and select_tag? I am happy atleast if I get a method to pass a name and id to the select_tag, so that the display is name and id is posted. regards, raj --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
See following for detailed doc: http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000399 Here is an example: <%= select("object","selection",[option1, option2,...], {}, {:class => "class"}) %> Should give you a drop-down with the current value of @object.selection selected. Help that helps --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks a lot for your reply, Kim. On 12/1/06, Kim <Kim.Griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <%= select("object","selection",[option1, option2,...], {}, {:class => > "class"}) %>I want the dropdown for a model less form. So I do not have an "object". I did solve this by a an ugly way. my form is: <%= form_tag :action => :agent_call_list%> <%= @agent = Agent.find (:all, :order => "name") collection_select("blah", :agent_id, @agent, :id, :name) -%> <%= submit_tag -%> <%= end_form_tag %> in my controller, I give: params[''agent_id''] = params[''blah''][''agent_id''] if params.has_key?("blah") params[''agent_id''] is used by other forms and that''s the place I expect the value to be. So I check if params[''blah''][''agent_id''] is defined and if so, I copy it''s value to params[''agent_id''] Ugly, but works. Though I would have preferred the value from the form in params[''agent_id''] Now if only I can select a particular value in my drop down list. raj --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---