Fields_for and form_remote_for not work properly

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 ?

On Jul 4, 5:53 pm, fmh [email protected] 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

/////////// 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 "", "$ (this).up('tr').remove()" %> <% else %> <%= link_to_delete :notifications,:destroy,notification.id %>
  <%end%>
</td>
<% end -%>

any help?

any help?

with form_for :

Parameters: {“company”=>{“new_notification_attributes”=>[{“label”=>"",
“email”=>""}, {“label”=>"", “email”=>""}],
“existing_notification_attributes”=>{“3”=>{“label”=>“test”,
“email”=>“[email protected]”}}}

with form_remote_for :

Parameters: {“company”=>{“new_notification_attributes”=>[{“label”=>""},
{ “email”=>""}, {“label”=>""}, {“email”=>""}],
“existing_notification_attributes”=>{“3”=>{“label”=>“test”,
“email”=>“[email protected]”}}}

???

On Jul 5, 3:10 pm, fmh [email protected] wrote:

with form_for :

Parameters: {“company”=>{“new_notification_attributes”=>[{“label”=>“”,
“email”=>“”}, {“label”=>“”, “email”=>“”}],
“existing_notification_attributes”=>{“3”=>{“label”=>“test”,
“email”=>“[email protected]”}}}

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