Form_remote_tag submitting to an rjs file

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 }) %>

<%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> <%= text_field 'order_item', 'quantity', :size => "5" %>

<%= 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

Hi Bill,

My code now looks like this:

<%= form_remote_tag( :html => { :action => url_for( :action =>
:add_item_to_order) }) %>

<%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> <%= text_field 'order_item', 'quantity', :size => "5" %> <%= submit_tag 'Add' %> <%= end_form_tag %>

and now nothing is being submitted (nothing at all happens when the
button is pressed.)

Any other ideas?

Thanks!

Hi Ryan,

Ryan L. 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

Ryan L. wrote:

Hi Bill,

My code now looks like this:

<%= form_remote_tag( :html => { :action => url_for( :action =>
:add_item_to_order) }) %>

<%=collection_select(:order_item , :item_category_id, @item_categories, :id, :name)%> <%= text_field 'order_item', 'quantity', :size => "5" %> <%= submit_tag 'Add' %> <%= 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?

Ryan L. wrote:

and now nothing is being submitted (nothing at all
happens when the button is pressed.)

Ahhh… progress :wink:

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

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.

Hi Ryan,

Ryan L. 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

/ 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

I will take a look at both! Thanks again for your help.