Michael S. Fischer
2006-Jul-31 23:21 UTC
[Rails] Text field not being submitted via form_remote_tag; works via form_tag
Hi everyone, Newbie here. I''m trying to get a textual form element to submit in the context of a form_remote_tag block and having little success. Oddly (or perhaps not), using regular old form_tag in its place does cause the elements to be submitted. Here''s the relevant partial ERb code: <%= form_remote_tag( { :url => { :action => :out, :id => pending_task } } ) %> <tr class="pending_task"> <td class="client_name"><%= pending_task.project.client.name %></td> <td class="project_name"><%= pending_task.project.name %></td> <td class="time_started"><%= pending_task.started_at %></td> <%= ''<td class="time elapsed" id="time_elapsed[%s]">'' % pending_task.id %><%distance_of_time_in_words(pending_task.started_at, Time.now) %></td> <td><%= submit_tag "Clock out" %></td> </tr> <%= ''<tr id="td_descr[%s]" style="display: none;">'' % pending_task.id %> <td colspan=5> Enter task description: <%= text_area "pending_task", "description" %> </td> </tr> <%= end_form_tag %> Initially, the row containing the textarea is hidden. When the user hits the submit button, the controller checks to see whether the textarea has been properly filled out. If so, it records the parameter; if not, it unhides the row and returns. Can someone tell me why the controller never sees pending_task[description]? Again, it does work properly if I use a standard form, but not its AJAXified cousin. Here''s the log data: Processing ClockController#out (for 127.0.0.1 at 2006-07-31 16:20:38) [POST] Session ID: ... Parameters: {"action"=>"out", "id"=>"9", "controller"=>"clock"} Regards, --Michael
Jeff Pritchard
2006-Aug-01 02:45 UTC
[Rails] Re: Text field not being submitted via form_remote_tag; work
Michael S. Fischer wrote:> Hi everyone, > > Newbie here. I''m trying to get a textual form element to submit in > the context of a form_remote_tag block and having little success. > Oddly (or perhaps not), using regular old form_tag in its place does > cause the elements to be submitted. Here''s the relevant partial ERb > code: > > <%= form_remote_tag( { :url => { :action => :out, :id => pending_task } > } ) %>Michael, Another newbie here offering a suggestion. Have you tried "text_area_tag" instead of "text_area"? Text area''s documentation left me a bit confused. "text_area_tag", on the other hand is simple and worked well for me in a similar situation. jp -- Posted via http://www.ruby-forum.com/.
Mark Reginald James
2006-Aug-02 07:17 UTC
[Rails] Re: Text field not being submitted via form_remote_tag; works via form_tag
Michael S. Fischer wrote:> <%= form_remote_tag( { :url => { :action => :out, :id => pending_task } > } ) %> > <tr class="pending_task">Forms must either span a whole table or be wholly inside a table cell. If you can''t put your form around the whole table because you need a separate one for each pair of rows, look at using the :submit option of submit_to_remote. -- We develop, watch us RoR, in numbers too big to ignore.
Michael S. Fischer
2006-Aug-03 00:54 UTC
[Rails] Re: Text field not being submitted via form_remote_tag; works via form_tag
On 8/2/06, Mark Reginald James <mrj@bigpond.net.au> wrote:> Michael S. Fischer wrote: > > > <%= form_remote_tag( { :url => { :action => :out, :id => pending_task } > > } ) %> > > <tr class="pending_task"> > > Forms must either span a whole table or be wholly inside a table cell. > If you can''t put your form around the whole table because you need a > separate one for each pair of rows, look at using the :submit option > of submit_to_remote.Do you mean the :with option? I don''t see a :submit option in the API documentation. Alternatively, do you mean the :submit option of link_to_remote? --Michael
Mark Reginald James
2006-Aug-03 01:23 UTC
[Rails] Re: Text field not being submitted via form_remote_tag; works via form_tag
Michael S. Fischer wrote:> On 8/2/06, Mark Reginald James > <mrj@bigpond.net.au> wrote: >> Forms must either span a whole table or be wholly inside a table cell. >> If you can''t put your form around the whole table because you need a >> separate one for each pair of rows, look at using the :submit option >> of submit_to_remote. > > Do you mean the :with option? I don''t see a :submit option in the API > documentation. Alternatively, do you mean the :submit option of > link_to_remote?submit_to_remote has a :submit option, though it is only implied in the API docs by stating that submit_to_remote has the same options as form_remote_tag, which in turn uses the same options as link_to_remote. But yes, :submit => row_id is equivalent to :with => "Form.serialize(''#{row_id}'')" -- We develop, watch us RoR, in numbers too big to ignore.