Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6721 (new defect)

Opened 3 years ago

Last modified 3 years ago

[PATCH] observe_form and observe_field should serialize form if :update parameter not supplied

Reported by: davidjrice Assigned to: David
Priority: normal Milestone: 1.2.7
Component: ActionPack Version: edge
Severity: normal Keywords: observe_form observe_field
Cc:

Description

According to the documentation for observe_field the :update parameter is not required. However if this is not supplied then the generated FormObserver does not supply parameters when submitting the request.

Assuming we have the following routes supplied

map.resources :users, :collection => [:validate => :post]

If we are using rjs to respond to this action, we don't want to supply an :update parameter, so we use the following;

<%= observe_form :user_form, :url => validate_users_path, :frequency => 2 %>

The javascript generated is the following; which does not work as no parameters are posted

//<![CDATA[
new Form.Observer('user_form', 2, function(element, value) {new Ajax.Request('/users;validate', {asynchronous:true, evalScripts:true})})
//]]>

The correct javascript would in fact be;

//<![CDATA[
new Form.Observer('user_form', 2, function(element, value) {new Ajax.Request('/users;validate', {asynchronous:true, evalScripts:true, parameters:value})})
//]]>

This can be resolved by changing the call to observe_form to;

<%= observe_form :user_form, :url => validate_users_path, :frequency => 2, :update = {} %>

With the included patch this hack is not required.

This fixes the defect raised in #5271, and may also be related to #6662 and #6553

Attachments

observer_should_pass_serialized_form_without_update_parameter.diff (2.4 kB) - added by davidjrice on 11/28/06 20:40:05.

Change History

11/28/06 20:40:05 changed by davidjrice

  • attachment observer_should_pass_serialized_form_without_update_parameter.diff added.

(in reply to: ↑ description ) 01/03/07 16:56:45 changed by jgarber

This bug has gotten me on more than one occasion. Let's get that patch applied, shall we?