# Observe\_form not serializing form

**URL:** <https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023>\
**Category:** Rails\
**Created:** [August 15, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023 "2006-08-15T18:57:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [August 15, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023/1 "2006-08-15T18:57:37Z")

</div>

I want to use observe\_form to automatically save notes in a text\_area.  
This is the code I have:

 \<%= text\_area :contact, :notes, :cols =\> 40, :rows =\> 10, :id =\>'notes\_text\_area' %\> \<%= observe\_form('notes\_form', :frequency =\> 1, :url =\> {:action =\> 'update\_notes', :contact\_id =\> @contact.contact\_id}) %\> 

For some reason, the contents of the text area are not being sent in the  
post. In fact it doesn’t appear that the form is being serialized at  
all. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [August 15, 2006, 9:09pm UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023/2 "2006-08-15T21:09:35Z")

</div>

On 8/15/06, Adam T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :contact_id => @contact.contact_id}) %>
> </form>
> 
> ```
> 
> For some reason, the contents of the text area are not being sent in the  
> post. In fact it doesn’t appear that the form is being serialized at  
> all. What am I doing wrong?

Hi,

I’ve been struggling with the same problem for a few days now. The api  
docs that describe the “:with” parameter to observe\_field/form are  
cryptic, to say the least.

After trying a number of semi-random strings I just now hit on a  
solution that seems to work: passing the string “value=value” as the  
:with param causes all of your form variables to show up in the POST  
params. I pass this on with the caveat that I haven’t the faintest  
idea why this works, and with no warranties that it won’t break in the  
future.

hth,  
James

–  
James H.  
Web application developer  
Vancouver, BC

“Developing a coherent political analysis is in many respects  
contingent upon an ability to connect one context to another, a  
process not dissimilar to playing the kid’s game of dot-to-dot.”

- Ward Churchill, from ‘“A Government of Laws”?’

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [August 15, 2006, 11:33pm UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023/3 "2006-08-15T23:33:55Z")

</div>

On 8/15/06, Adam T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Form.serialize(‘notes\_form’)})})  
> //]]\>

Yes, it’s definitely not working as advertised. One thing I’ve been  
trying to get working is having the response to the form observer  
inject new input elements into the form, and then have those new  
elements be ‘observed’ as well: no joy, though, it will only fire on  
events on form elements that were there when the form was first  
rendered.

Thanks for pointing out the serialize method above; I thought it might  
help with this issue but no. I’ve hardcoded this snippet into my app  
as well.

Has this been reported as a bug on the rails trac?

jh

> > idea why this works, and with no warranties that it won’t break in the  
> > "Developing a coherent political analysis is in many respects  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
James H.  
Web application developer  
Vancouver, BC

“Developing a coherent political analysis is in many respects  
contingent upon an ability to connect one context to another, a  
process not dissimilar to playing the kid’s game of dot-to-dot.”

- Ward Churchill, from ‘“A Government of Laws”?’

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [August 15, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023/4 "2006-08-15T21:16:55Z")

</div>

James, it has to be a bug. I just hard coded the javascript using the  
prototype library as the observe\_form function SHOULD do, and it works  
fine:

```
        //<![CDATA[
          new Form.Observer('notes_form', 1, function(element, 

```

value)  
{new  
Ajax.Request(‘/contacts/update\_notes?contact\_id=155’,  
{asynchronous:true, evalScripts:true, parameters:  
Form.serialize(‘notes\_form’)})})  
//]]\>

-Adam

James H. wrote:

> On 8/15/06, Adam T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ```
> > :contact_id => @contact.contact_id}) %>
> > </form>
> > 
> > ```
> > 
> > For some reason, the contents of the text area are not being sent in the  
> > post. In fact it doesn’t appear that the form is being serialized at  
> > all. What am I doing wrong?
> 
> Hi,
> 
> I’ve been struggling with the same problem for a few days now. The api  
> docs that describe the “:with” parameter to observe\_field/form are  
> cryptic, to say the least.
> 
> After trying a number of semi-random strings I just now hit on a  
> solution that seems to work: passing the string “value=value” as the  
> :with param causes all of your form variables to show up in the POST  
> params. I pass this on with the caveat that I haven’t the faintest  
> idea why this works, and with no warranties that it won’t break in the  
> future.
> 
> hth,  
> James
> 
> –  
> James H.  
> Web application developer  
> Vancouver, BC
> 
> “Developing a coherent political analysis is in many respects  
> contingent upon an ability to connect one context to another, a  
> process not dissimilar to playing the kid’s game of dot-to-dot.”
> 
> - Ward Churchill, from ‘“A Government of Laws”?’

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [August 16, 2006, 2:03am UTC](https://www.ruby-forum.com/t/observe-form-not-serializing-form/65023/5 "2006-08-16T02:03:03Z")

</div>

I tried reporting it as a bug today, but the bugtracking system was  
unreachable…

-Adam

James H. wrote:

> On 8/15/06, Adam T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Form.serialize(‘notes\_form’)})})  
> > //]]\>
> 
> Yes, it’s definitely not working as advertised. One thing I’ve been  
> trying to get working is having the response to the form observer  
> inject new input elements into the form, and then have those new  
> elements be ‘observed’ as well: no joy, though, it will only fire on  
> events on form elements that were there when the form was first  
> rendered.
> 
> Thanks for pointing out the serialize method above; I thought it might  
> help with this issue but no. I’ve hardcoded this snippet into my app  
> as well.
> 
> Has this been reported as a bug on the rails trac?
> 
> jh
> 
> > > idea why this works, and with no warranties that it won’t break in the  
> > > "Developing a coherent political analysis is in many respects  
> > > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> –  
> James H.  
> Web application developer  
> Vancouver, BC
> 
> “Developing a coherent political analysis is in many respects  
> contingent upon an ability to connect one context to another, a  
> process not dissimilar to playing the kid’s game of dot-to-dot.”
> 
> - Ward Churchill, from ‘“A Government of Laws”?’
