# Repeating fields on the same page

**URL:** <https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052>\
**Category:** rubyonrails-talk\
**Created:** [March 10, 2010, 10:13pm UTC](https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052 "2010-03-10T22:13:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dudebot](https://discuss.rubyonrails.org/u/Dudebot)\
**Post date:** [March 10, 2010, 10:13pm UTC](https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052/1 "2010-03-10T22:13:24Z")

</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| %\> &nbsp;&nbsp;&nbsp;\<%= f.submit "DoIt" %\> &nbsp;&nbsp;&nbsp;\<%= f.text\_field :value %\> &nbsp;&nbsp;&nbsp;\<%= 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:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [March 11, 2010, 8:10am UTC](https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052/2 "2010-03-11T08:10:38Z")

</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?

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:** ![Christophe1](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Christophe1](https://discuss.rubyonrails.org/u/Christophe1)\
**Post date:** [March 11, 2010, 9:33am UTC](https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052/3 "2010-03-11T09:33:16Z")

</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

---

<div class="post-metadata">

**Author:** ![Dudebot](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dudebot](https://discuss.rubyonrails.org/u/Dudebot)\
**Post date:** [March 11, 2010, 11:59am UTC](https://discuss.rubyonrails.org/t/repeating-fields-on-the-same-page/50052/4 "2010-03-11T11:59:22Z")

</div>

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
