# Fields\_for and form\_remote\_for not work properly

**URL:** <https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077>\
**Category:** Rails\
**Created:** [July 4, 2010, 6:54pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077 "2010-07-04T18:54:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 4, 2010, 6:54pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/1 "2010-07-04T18:54:52Z")

</div>

I think I’m not the first to ask this question.

I have a fields\_for within a form\_remote\_for and this not work  
properly , the remote\_form\_for serialize strangely all params passed  
by fields\_for.

with a form\_for it’s work perfectly.

Rails -v = 2.3.8

any help ?

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 4, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/2 "2010-07-04T19:00:08Z")

</div>

On Jul 4, 5:53 pm, fmh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I think I’m not the first to ask this question.
> 
> I have a fields\_for within a form\_remote\_for and this not work  
> properly , the remote\_form\_for serialize strangely all params passed  
> by fields\_for.

What do the params look like ? What does your form look like ?

Fred

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 4, 2010, 7:31pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/3 "2010-07-04T19:31:10Z")

</div>

/////////// Partial  
\<%= error\_messages\_for :company %\>  
\<% form\_remote\_for :company , :url =\>{:action  
=\> :update\_notif} , :html=\>{} do |f| -%\>

 \<%= add\_notification\_link("Add notification") %\> \<%= render :partial =\> "companies/notification" , :collection =\> @company.notifications%\> 

| Email | Label |
| --- | --- |

\<%= f.submit "Save"%\>

```
<%end%>

```

////////// \_notification.html.erb

\<% new\_or\_existing = notification.new\_record? ? ‘new’ : ‘existing’ %\>  
\<% prefix = “company[#{new\_or\_existing}\_notification\_attributes][]” %\>  
\<% fields\_for prefix, notification do |notification\_form| -%\>

 \<% id = new\_or\_existing == "new" ? "company\_new\_notification\_attributes\_email" : nil %\> \<%= notification\_form.text\_field\_with\_auto\_complete :email, {:id=\> id} , {:url =\> {:controller=\>:autocompletes , :action=\>"for\_company\_notifications\_email"}, :method =\> :get, :frequency=\>0.2, :skip\_style =\> true, :select =\>"email", :with =\> "'text\_field\_val=' + element.value" } %\> \<%= notification\_form.text\_field(:label) %\> \<% if new\_or\_existing == "new" %\> \<%= link\_to\_function " ![](https://www.ruby-forum.com/images/delete.png)", "$ (this).up('tr').remove()" %\> \<% else %\> \<%= link\_to\_delete :notifications,:destroy,notification.id %\>

```
  <%end%>
</td>

```

 \<% end -%\>

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 5, 2010, 10:52am UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/4 "2010-07-05T10:52:26Z")

</div>

any help?

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 5, 2010, 11:13am UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/5 "2010-07-05T11:13:30Z")

</div>

any help?

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 5, 2010, 4:11pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/6 "2010-07-05T16:11:28Z")

</div>

with form\_for :

Parameters: {“company”=\>{“new\_notification\_attributes”=\>[{“label”=\>"",  
“email”=\>""}, {“label”=\>"", “email”=\>""}],  
“existing\_notification\_attributes”=\>{“3”=\>{“label”=\>“test”,  
“email”=\>“removed\_email\_address@domain.invalid”}}}

with form\_remote\_for :

Parameters: {“company”=\>{“new\_notification\_attributes”=\>[{“label”=\>""},  
{ “email”=\>""}, {“label”=\>""}, {“email”=\>""}],  
“existing\_notification\_attributes”=\>{“3”=\>{“label”=\>“test”,  
“email”=\>“removed\_email\_address@domain.invalid”}}}

???

---

<div class="post-metadata">

**Author:** ![fmh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a698b9/32.png) [@fmh](https://www.ruby-forum.com/u/fmh)\
**Post date:** [July 5, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/fields-for-and-form-remote-for-not-work-properly/191077/7 "2010-07-05T17:56:17Z")

</div>

On Jul 5, 3:10 pm, fmh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> with form\_for :
> 
> Parameters: {“company”=\>{“new\_notification\_attributes”=\>[{“label”=\>“”,  
> “email”=\>“”}, {“label”=\>“”, “email”=\>“”}],  
> “existing\_notification\_attributes”=\>{“3”=\>{“label”=\>“test”,  
> “email”=\>“removed\_email\_address@domain.invalid”}}}

Have you had a look at the actual body of the post (ie before rails  
tries to parse it)? at a guess it looks like prototype may be  
serializing the form in an unexpected way. Can you reduce this to a  
minimal test case ?

Fred
