I have the following form that I am trying to use, but for some reason, the form gets submitted with out the params values. <%= form_remote_tag(:url => { :action => :add_item_to_order }) %> <tr> <td> <%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> </td> <td> <%= text_field ''order_item'', ''quantity'', :size => "5" %> </td> <%= submit_tag ''Add'' %> This outputs at the server: Processing OrderController#add_item_to_order (for 127.0.0.1 at 2006-07-06 13:40:32) [POST] Session ID: 12a539f773a693a5ce75a8a77082e7dd Parameters: {"action"=>"add_item_to_order", "controller"=>"order"} Without any parameters. Can I not submit my form elements with a form_remote_tag ? Thanks for the help! Ryan -- Posted via http://www.ruby-forum.com/.
Hi Ryan, Ryan Lundie wrote:>I have the following form that I am trying to use, > but for some reason, the form gets submitted with > out the params values. > > <%= form_remote_tag(:url => { :action => :add_item_to_order }) %>According to the example in the Rails documentation (http://api.rubyonrails.org/) the syntax for form_remote_tag is: form_remote_tag :html => {:action => url_for(...}} Then it says... "The Hash passed to the :html key..." So I think the problem is that your code is not telling it where to pass the params hash. Try... <%= form_remote_tag( :html => { :action => url_for( :action => :add_item_to_order) }) %> hth, Bill
Hi Bill, My code now looks like this: <%= form_remote_tag( :html => { :action => url_for( :action => :add_item_to_order) }) %> <tr> <td> <%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> </td> <td> <%= text_field ''order_item'', ''quantity'', :size => "5" %> </td> <td> <%= submit_tag ''Add'' %> </td> </tr> <%= end_form_tag %> and now nothing is being submitted (nothing at all happens when the button is pressed.) Any other ideas? Thanks! -- Posted via http://www.ruby-forum.com/.
Ryan Lundie wrote:> Hi Bill, > > My code now looks like this: > > <%= form_remote_tag( :html => { :action => url_for( :action => > :add_item_to_order) }) %> > <tr> > <td> > <%=collection_select(:order_item , :item_category_id, > @item_categories, :id, :name)%> > > </td> > <td> > <%= text_field ''order_item'', ''quantity'', :size => "5" %> > </td> > <td> > <%= submit_tag ''Add'' %> > </td> > </tr> > <%= end_form_tag %> > > and now nothing is being submitted (nothing at all happens when the > button is pressed.) > > Any other ideas? > > Thanks!What does your add action do? Look at your development.log file (assuming you''re in development mode) to see what the form is passing to the "add" action...any errors? -- Posted via http://www.ruby-forum.com/.
Your not going to believe this, but the reason it wasn''t working was because the form was within table tags. Apperently you cannot place the form tags within table tags. (I found it here: http://lists.rubyonrails.org/pipermail/rails/2006-May/039186.html) Thanks again for your help, this was driving me mad. -- Posted via http://www.ruby-forum.com/.
Ryan Lundie wrote:> > and now nothing is being submitted (nothing at all > happens when the button is pressed.)Ahhh.... progress ;-)> Any other ideas?If you''re not already using it, get Firefox. Then download Firebug. It will let you see what''s being sent, what errors are being generated, etc. One of the challenges with using RJS is that while the error pages you''re used to getting from Rails are, in fact, being generated, they''re not being displayed. Firebug will let you see the response. hth, Bill
Hi Ryan, Ryan Lundie wrote:> Your not going to believe this, but the reason it wasn''t > working was because the form was within table tags.My rather strong advice is stop using tables for layout and move to using <div> / <span> and CSS for same. I''ve found http://www.w3schools.com/ to be a tremendous resource for this making it very easy to pick up all the basics. It''s also a terriffic resource for understanding the ''html options'' you''ll find referred to very frequently in the Rails documentation. Best regards, Bill