I''ve run into what I think is a browser bug related to using remote_forms pushed in an RJS update. In my controller, I have an action that creates a new model and returns a form for one of its children: def create_party party = Party.create render :update do |page| page.insert_html :top, ''party-list'', :partial => ''party_header'', :locals => { :party => party } page.insert_html :after, "party-#{party.id}", :partial => ''guest_form'', :locals => { :guest => party.guests.build } end end _guest_form.rhtml is: <tr> <% remote_form_for :guest, guest, :url => { :action => ''create_guest'' } do |f| %> <%= f.hidden_field :party_id %> <td><%= f.text_field :first_name %></td> <td><%= f.text_field :last_name %> <%= submit_tag %></td> <% end %> </tr> Unfortunately, when the form is submitted, params[] contains only the party_id, and not the other values I?ve typed in (not even a blank value for the key). It?s either a browser problem, due to issues with programmatically-generated content, or something strange in Form.serialize. Has anyone else run into this issue? I don?t think I?m doing anything particularly boneheaded here? -- Posted via http://www.ruby-forum.com/.
Benjamin Stiglitz wrote:> def create_party > party = Party.create > render :update do |page| > page.insert_html :top, ''party-list'', :partial => ''party_header'', > :locals => { :party => party } > page.insert_html :after, "party-#{party.id}", :partial => > ''guest_form'', :locals => { :guest => party.guests.build } > end > endUse page.insert_html :top, ''party-list'', :partial => ''party_header'', :object => party instead And for guest page.insert_html :after, "party-#{party.id}", :partial => ''guest_form'', :object => party.guests.build> _guest_form.rhtml is: > <tr> > <% remote_form_for :guest, guest, :url => { :action => ''create_guest'' > } do |f| %> > <%= f.hidden_field :party_id %> > <td><%= f.text_field :first_name %></td> > <td><%= f.text_field :last_name %> <%= submit_tag %></td> > <% end %> > </tr>HTH Dj T@l -- Posted via http://www.ruby-forum.com/.
>> def create_party >> party = Party.create >> render :update do |page| >> page.insert_html :top, ''party-list'', :partial => ''party_header'', >> :locals => { :party => party } >> page.insert_html :after, "party-#{party.id}", :partial => >> ''guest_form'', :locals => { :guest => party.guests.build } >> end >> end > > Use page.insert_html :top, ''party-list'', :partial => ''party_header'', > :object => party instead > And for guest > page.insert_html :after, "party-#{party.id}", :partial => ''guest_form'', > :object => party.guests.buildAFAIK, :locals has replaced the old :object spec. In any case, the change above breaks the party_id field. The issue is not that the rendered form is not displaying properly?it?s that submitting that form omits field values. -Ben -- Posted via http://www.ruby-forum.com/.