Form - Tick boxes in related table


#1

Sure this one is solved somewhere, but couldn’t find it.

I have a table which has a related table (has many through). I wish
to choose 1 or more items in the related table with a check box. For
example, if I had a table with group one, group two and group three
and a list of clients. I would like to have a form so that given a
client, (in the edit client form), I can assign a client to one or
more groups.

How would I construct a form to achieve this using a reasonable
succinct controller?

Many thanks,

Mike


#2

On Tue, Apr 21, 2009 at 2:46 PM, mikej removed_email_address@domain.invalid wrote:

How would I construct a form to achieve this using a reasonable
succinct controller?

Many thanks,

Mike

Have a look at fields_for which you can use for linked models
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001573

There is also Nested Object Forms in Rails 2.3
http://guides.rubyonrails.org/2_3_release_notes.html#nested-object-forms

Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain