views:

2026

answers:

2

Hello, my question involves the following partial view with a remote form:

 <% remote_form_for :phone_number, :url => {:controller => "edit", :action => "add_phone_number" }, :update => "phone_number_div" do |form| %>
 <%= form.text_field :number%>
 <%= form.select :type, PhoneNumber::PHONE_TYPE%>
 <%= submit_tag "Add" %>  
 <% end %>

When the Add button is pressed, the add_phone_number action is posted to, but the form values are not in the params variable.

Does anyone know why this could be?

A: 

You probably want to have some sort of method for the form.

<% remote_form_for :phone_number, :method => :post, :url => { :controller => "edit", :action => "add_phone_number" }, :update => "phone_number_div" do |form| %>

Not to be picky but if you are using remote_for_form you want to have a resource to use it with. So you would want to replace :phone_number with @phone_number an instance variable that you instantiated in your controller. This keeps the code a little nicer and it is also in keeping with the conventions of Rails.

Also for problems like these debugger is your friend

vrish88
+3  A: 

Most browsers won't pass the form values in the post if the form element is a child node in an illegal location in the DOM (like inside a TR, for example (and not in a TD). I ran into this problem once.

More info at my blog post.

Gabe Hollombe
Was this actually the problem in your case?
Gabe Hollombe
yes it was exactly the problem. Thank you
rube_noob