# Fields\_for with div\_for

**URL:** <https://www.ruby-forum.com/t/fields-for-with-div-for/171123>\
**Category:** Rails\
**Created:** [June 26, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/fields-for-with-div-for/171123 "2009-06-26T17:52:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [June 26, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/fields-for-with-div-for/171123/1 "2009-06-26T17:52:32Z")

</div>

Hi there. I have a parent/child relationship/form and using the swanky  
accepts\_nested\_attributes\_for to submit the data for the child. Now this  
is really great, but when I come to editing an existing child through  
parent I wish to wrap the generated fields with a div.  
So:

\<% form\_for(@parent) do |parent\_form| %\>  
\<% parent\_form.fields\_for :children do |children\_form| %\>  
\<% div\_for(??) do %\>

For each iteration I would like to surround the generated hidden id  
field, and those I add myself, in a div.

So…

Using:  
children\_form.object  
I can access the attributes of the object. It is of the class ‘Child’ as  
it should be. However, div\_for will not accept children\_form.object as  
an active record object and subsequently wrap each iterated child record  
with the div:

This does not work:  
\<% div\_for(children\_form.object) do %\>

Any help would be much appreciated\> 🙂
