This problem is very strange. I’ve included a very simple controller and
a very simple view that you can drop into any rails environment to test
this problem out.
When I submit a form, and the form is inside a table (say a row in a
table) then the parameters sent on the form submission are different
than if the form is not in a table.
When I run a simple test and I submit a form created with a
“form_remote_tag” method and this form is inside a table,
@params.inspect gives the following:
{“action”=>“ajax_submit”, “controller”=>“ajax_problem”}
Most notable here is that there are no parameters from the form sent in.
The exact same form created outside of a table generates the following:
{“commit”=>“Submit (no table)”, “action”=>“ajax_submit”,
“some_param”=>“a value I typed in”, “controller”=>“ajax_problem”,
“_”=>""}
Vastly different results. The exact controller and view that I used to
obtain these results are included below. Just cut-and-paste the
controller into app/controllers/ajax_problem_controller.rb and put the
view in app/views/ajax_problem/index.rhtml, then test it out. If anyone
can explain to me what I’m doing wrong and how to fix it, it would be
most appreciated.
******** Sample code ************************
** Here is a very simple controller:
class AjaxProblemController < ApplicationController
layout nil
def index
end
def ajax_submit
render_text @params.inspect
end
end
** Here is a very simple view to show the problem:
Ajax Problem <%= javascript_include_tag "prototype" %><%= text_field_tag 'some_param' %> | <%= submit_tag "Submit (with a table)" %> | <%= end_form_tag %>
Now outside of a table <br/>
<br/>
<%= form_remote_tag(:update => "to_update",
:url => { :action => :ajax_submit }
) %>
<%= text_field_tag 'some_param' %>
<%= submit_tag "Submit (no table)" %>
<%= end_form_tag %>