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: <html> <head> <title>Ajax Problem</title> <%= javascript_include_tag "prototype" %> </head> <body> <div id="to_update"> </div> <table> <tr> <%= form_remote_tag(:update => "to_update", :url => { :action => :ajax_submit } ) %> <td> <%= text_field_tag ''some_param'' %> </td> <td> <%= submit_tag "Submit (with a table)" %> </td> <%= end_form_tag %> </tr> </table> 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 %> </body> </html>
For got to include: Rails 0.14.3 Ruby 1.8.2 Gentoo Matthew Thill wrote:> 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: > > <html> > <head> > <title>Ajax Problem</title> > <%= javascript_include_tag "prototype" %> > </head> > <body> > <div id="to_update"> > </div> > <table> > <tr> > <%= form_remote_tag(:update => "to_update", > :url => { :action => :ajax_submit } > ) %> > <td> > <%= text_field_tag ''some_param'' %> > </td> > <td> > <%= submit_tag "Submit (with a table)" %> > </td> > <%= end_form_tag %> > </tr> > </table> > > 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 %> > </body> > </html> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Matt, I just did the test, with your exact code and got proper results. {"commit"=>"Submit (with a table)", "action"=>"ajax_submit", "some_param"=>"Michael", "controller"=>"ajax_problem", "_"=>""} {"commit"=>"Submit (no table)", "action"=>"ajax_submit", "some_param"=>"Michael", "controller"=>"ajax_problem", "_"=>""} This is from IE 6.0. Looks like it may be a versioning issue somewhere...I just wanted to let you know that the code is proper - at least from my config. Regards, Michael Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote: For got to include: Rails 0.14.3 Ruby 1.8.2 Gentoo Matthew Thill wrote:> 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: > > > > > > > > >> > > "to_update", > :url => { :action => :ajax_submit } > ) %> > > > > > > > > > > > Now outside of a table>> "to_update", > :url => { :action => :ajax_submit } > ) %> > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails --------------------------------- Yahoo! FareChase - Search multiple travel sites in one click. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Form inside Table is not valid HTML. The Ajax call is based on some javascript code collecting the values of the parameters. When the form is inside the table, that code is unable to find any children of the form. (most likely because you placed those parameters like <td><%=text_field ''obj'',''param'' %></td>) So instead of: <table> <form> <tr><td><input></td></tr> </form> </table> use <form> <table> <tr><td><input></td></tr> </table> </form> and it would work fine Bogdan On 11/14/05, Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote:> > 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: > > <html> > <head> > <title>Ajax Problem</title> > <%= javascript_include_tag "prototype" %> > </head> > <body> > <div id="to_update"> > </div> > <table> > <tr> > <%= form_remote_tag(:update => "to_update", > :url => { :action => :ajax_submit } > ) %> > <td> > <%= text_field_tag ''some_param'' %> > </td> > <td> > <%= submit_tag "Submit (with a table)" %> > </td> > <%= end_form_tag %> > </tr> > </table> > > 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 %> > </body> > </html> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
That''s good to know, thank you. I''ll try to borrow someone''s Windows machine and test. I was using Firefox 1.0.7. Browser issues? Anyone else out there able to get the crazy results I was getting? Michael wrote:> Matt, > > I just did the test, with your exact code and got proper results. > > {"commit"=>"Submit (with a table)", "action"=>"ajax_submit", "some_param"=>"Michael", "controller"=>"ajax_problem", "_"=>""} > > {"commit"=>"Submit (no table)", "action"=>"ajax_submit", "some_param"=>"Michael", "controller"=>"ajax_problem", "_"=>""} > > This is from IE 6.0. Looks like it may be a versioning issue somewhere...I just wanted to let you know that the code is proper - at least from my config. > > Regards, > > Michael > > > Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote: > For got to include: > Rails 0.14.3 > Ruby 1.8.2 > Gentoo > > Matthew Thill wrote: > >>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: >> >> >> >> >> >> >> >> >> > > >> >> "to_update", >> :url => { :action => :ajax_submit } >> ) %> >> >> >> >> >> >> >> >> >> >> >>Now outside of a table > > > >> "to_update", >> :url => { :action => :ajax_submit } >> ) %> >> >> >> >> >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > --------------------------------- > Yahoo! FareChase - Search multiple travel sites in one click. > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thank you, that was it. I would have thought that you could make just one row of a table into a form (as I did) but I guess this is not valid html, as you said. I can now confirm what an earlier poster said, that IE 6 does do what I expect. IE 6 supporting non-standard html? I''m shocked. Bogdan Ionescu wrote:> Form inside Table is not valid HTML. > The Ajax call is based on some javascript code collecting the values of the > parameters. > When the form is inside the table, that code is unable to find any children > of the form. (most likely because you placed those parameters like > <td><%=text_field ''obj'',''param'' %></td>) > So instead of: > <table> > <form> > <tr><td><input></td></tr> > </form> > </table> > use > <form> > <table> > <tr><td><input></td></tr> > </table> > </form> > and it would work fine > > Bogdan > > > > On 11/14/05, Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote: > >>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: >> >><html> >><head> >><title>Ajax Problem</title> >><%= javascript_include_tag "prototype" %> >></head> >><body> >><div id="to_update"> >></div> >><table> >><tr> >><%= form_remote_tag(:update => "to_update", >>:url => { :action => :ajax_submit } >>) %> >><td> >><%= text_field_tag ''some_param'' %> >></td> >><td> >><%= submit_tag "Submit (with a table)" %> >></td> >><%= end_form_tag %> >></tr> >></table> >> >>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 %> >></body> >></html> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
IE has always been a pain in the ass for web developers, so I am shocked that you are shocked ;) On 11/14/05, Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote:> > Thank you, that was it. I would have thought that you could make just > one row of a table into a form (as I did) but I guess this is not valid > html, as you said. > > I can now confirm what an earlier poster said, that IE 6 does do what I > expect. IE 6 supporting non-standard html? I''m shocked. > > Bogdan Ionescu wrote: > > Form inside Table is not valid HTML. > > The Ajax call is based on some javascript code collecting the values of > the > > parameters. > > When the form is inside the table, that code is unable to find any > children > > of the form. (most likely because you placed those parameters like > > <td><%=text_field ''obj'',''param'' %></td>) > > So instead of: > > <table> > > <form> > > <tr><td><input></td></tr> > > </form> > > </table> > > use > > <form> > > <table> > > <tr><td><input></td></tr> > > </table> > > </form> > > and it would work fine > > > > Bogdan > > > > > > > > On 11/14/05, Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote: > > > >>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: > >> > >><html> > >><head> > >><title>Ajax Problem</title> > >><%= javascript_include_tag "prototype" %> > >></head> > >><body> > >><div id="to_update"> > >></div> > >><table> > >><tr> > >><%= form_remote_tag(:update => "to_update", > >>:url => { :action => :ajax_submit } > >>) %> > >><td> > >><%= text_field_tag ''some_param'' %> > >></td> > >><td> > >><%= submit_tag "Submit (with a table)" %> > >></td> > >><%= end_form_tag %> > >></tr> > >></table> > >> > >>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 %> > >></body> > >></html> > >>_______________________________________________ > >>Rails mailing list > >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails