# Complex Form

**URL:** <https://www.ruby-forum.com/t/complex-form/134356>\
**Category:** Rails\
**Created:** [April 10, 2008, 2:56am UTC](https://www.ruby-forum.com/t/complex-form/134356 "2008-04-10T02:56:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 2:56am UTC](https://www.ruby-forum.com/t/complex-form/134356/1 "2008-04-10T02:56:41Z")

</div>

I’m rending a form of a table in a partial. The rows can be adjusted  
dynamically. How do I write  
1  
2  
3  
4  
5  
??

\<%= render :partial =\> ‘round’, :collection =\> @game.rounds %\>

\<% fields\_for\_round(round) do |round\_form| %\> \<%= ROW??? %\> \<% end %\>

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 5:13am UTC](https://www.ruby-forum.com/t/complex-form/134356/2 "2008-04-10T05:13:35Z")

</div>

if all you want is the count for the current partial being rendered  
you have it in round\_counter

[http://ap.rubyonrails.com/classes/ActionView/Partials.html](http://ap.rubyonrails.com/classes/ActionView/Partials.html)

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 5:26am UTC](https://www.ruby-forum.com/t/complex-form/134356/3 "2008-04-10T05:26:27Z")

</div>

Hi.

You’re rendering a form of a table in a partial.

Tables don’t have forms.

Do you mean a form for some data in a DATABASE table?

That doesn’t make sense, either.

perhaps you mean you’re rendering a form for a MODEL which is relying  
on data in a database table?

If that’s the case, that’s fine.

Now, you say the rows can be adjusted dynamically.

Do you mean the rows can be adjusted by the user, when they’re looking  
at the page, using AJAX?

Or do you mean they’re programmatically driven?

what does: how do I write 1 2 3 4 5 … mean?

Do you mean how do I write the numbers from 1 to some arbitrary number?

Or do you mean how do I label my rows, given a varying number of  
records to be displayed, or something else?

BE MORE SPECIFIC! GET CLEAR!

Do you understand why I’m being like this, now?

Programming is a specific art, and you need to be very clear in your  
mind if you want to understand the reason things happen the way they  
do and fundamentally understand what processes are going on underneath  
“the hood” so to speak.

I’m saying this because I care. Most people on this list will just  
look at your questions and treat them like rubbish, because it’s too  
hard to grok what you’re attempting to ask from your “Question”.

You can do this, I know you can - clearly write out your requirements  
for us so we can help you with them. Specify every little detail -  
exactly what you want to accomplish.

Julian

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
VIDEO #3 out NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 5:51am UTC](https://www.ruby-forum.com/t/complex-form/134356/4 "2008-04-10T05:51:37Z")

</div>

Okay. I’ve got it now. You’ve been very helpful thanks.

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 6:47am UTC](https://www.ruby-forum.com/t/complex-form/134356/5 "2008-04-10T06:47:46Z")

</div>

Actually I was asking these questions to gather responses from you so  
we can further help…

If you respond to the questions, then we can potentially get to the  
bottom of solving your issue(s).

Sorry if I’m coming across as narky. I think I need more sleep, and  
less coffee.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
VIDEO #3 out NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 10, 2008, 6:57am UTC](https://www.ruby-forum.com/t/complex-form/134356/6 "2008-04-10T06:57:07Z")

</div>

## edit game
\<% form\_for :game, :url =\> school\_team\_game\_url(School.find(current\_user.school\_id), Team.find\_by\_user\_id(current\_user), @game), :html =\> { :method =\> 'put' } do |f| %\> \<%= render :partial =\> 'fields', :locals =\> { :f =\> f } %\> 

\<%= submit\_tag "Submit Game" %\>

\<% end %\>

…

```
  <%= render :partial => 'round', :collection => @game.rounds %>

```

…

\<% fields\_for\_round(round) do |round\_form| %\> \<% @class = cycle("", "alt", :name =\> "colors") -%\> \<% 3.times do |p| %\> \<%= round\_form.select(:action, ["Miss", "Skip", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]) %\> \<%= round\_form.hidden\_field :player\_id, :value =\> Team.find\_by\_user\_id(current\_user).players[p].id %\>

#\<%= round\_form.hidden\_field :row\_id, :value =\> round\_counter + 1 %\>\</  
td\>  
#it keeps repeating 2 every time i hit Add Round. It needs to keep  
counting up!

\<% end %\>

 \<%= round\_counter + 1 %\>

\<% 3.times do |p| %\>

\<%= round\_form.select(:action, [“Miss”,  
“Skip”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”]) %\>  
\<%= round\_form.hidden\_field :player\_id, :value =\>  
Team.find\_by\_user\_id(current\_user).players[p].id %\>  
\<% end %\>  
\<% end %\>
