I need to create a form for an account
resource. In this form I need to collect some set of identifiers as an array in the params
hash in the relationships
attribute.
So, the final params[account]
hash from the POST request should look like this:
{:name => 'somename', :relationships => ["123", "23", "23445"]}
How do I create form_for
fields? I tried this but did not work:
<%= form_for @account do |f| %> <%= f.text_field :name %> <% @eligible_parents.each do |p| %> <%= f.check_box "relationships", nil, :value => p.id %> <b><%= p.name %></b><br/> </span> <% end %> <%= f.submit "Submit" %> <% end %>
The number of elements in @eligible_parents
changes each time.
relationships
is neither an association nor an attribute in the account
model.
I need to use virtual attributes, but I need to fill an array from the form.
Please, help. How can i do this?
source share