# Repeating fields on the same page

**URL:** <https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956>\
**Category:** Rails\
**Created:** [March 10, 2010, 11:15pm UTC](https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956 "2010-03-10T23:15:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 10, 2010, 11:15pm UTC](https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956/1 "2010-03-10T23:15:17Z")

</div>

Does anyone know how I can repeat fields for a model (that would  
insert into different records) in a form? E.g.

\<% form\_for @thing, do |f| %\>  
\<%= f.submit “DoIt” %\>  
\<%= f.text\_field :value %\>  
\<%= f.text\_field :value %\>  
\<% end %\>

So that somehow when the user pressed “DoIt”, the first value would go  
into a record in thing, and the second value would go into another  
record? Is this possible?

TIA,  
Craig

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 11, 2010, 12:05pm UTC](https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956/2 "2010-03-11T12:05:32Z")

</div>

On Mar 10, 10:13 pm, Dudebot [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> into a record in thing, and the second value would go into another  
> record? Is this possible?

As long as you give the fields different names (or nest them in a  
different scope, eg with fields\_for), then yes. You just need to do  
different things with params[:thing][:value1] and params[:thing]  
[:value2] in your controller

Fred

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 11, 2010, 12:15pm UTC](https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956/3 "2010-03-11T12:15:29Z")

</div>

You probably should have a look into :

> **[\#73 Complex Forms Part 1 - RailsCasts](http://railscasts.com/episodes/73-complex-forms-part-1)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

Christophe

Le 10 mars 2010 à 23:13, Dudebot a écrit :

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 11, 2010, 1:00pm UTC](https://www.ruby-forum.com/t/repeating-fields-on-the-same-page/184956/4 "2010-03-11T13:00:36Z")

</div>

On Mar 11, 2:10 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Does anyone know how I can repeat fields for a model (that would  
> > insert into different records) in a form?  
> > As long as you give the fields different names (or nest them in a  
> > different scope, eg with fields\_for), then yes. You just need to do  
> > different things with params[:thing][:value1] and params[:thing]  
> > [:value2] in your controller  
> > Fred

On Mar 11, 3:33 am, Christophe D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You probably should have a look into :  
> [#73 Complex Forms Part 1 - RailsCasts](http://railscasts.com/episodes/73-complex-forms-part-1)  
> Christophe

Thanks, Fred and Christophe. I had found the railscast on updating  
multiple fields, but that wasn’t exactly what I was looking for. I’ll  
watch the complex forms railscasts, mock up some code and get back to  
the group if I remain too stupid.  
Craig
