form params help

Zac Elston
Wed, 13 Sep 2006 20:12:11 -0000

I''ve got a form where I have several items ("packages")
listed  and I
want to query a param that should contain all the "packages" from the
form in the controller.  However I''m only getting the first item
returned.

a working example is HATBM checkboxes where
<input id="package[names][]" name="package[names][]"
type="checkbox"
value="z1" />
vs
<input id="package_names" name="package[names]"
type="text" value="z1"
/>

how do I get the name="object[method][]

here''s the rhtml

<%= start_form_tag :action => ''push'' %>
<% @packages.each do |p| %>
<%= hidden_field ''package'', ''Name'',
:value => p.Name  %>
<% end %>
  <%= submit_tag "PushIT" %>
<%= end_form_tag %>

my controller (just a skeleton at the moment to debug

def push

 @params = params
  @pkgparams = params[:package][:Name]

end

my result is only the first package from the |p| loop.

How do I get multiple text fields to collect into a param with the same
name like a checkbox does?

thanks

-zac