dino d.
2009-May-05 15:07 UTC
select_tag with multiple set to true returns a String in params instead of array
Hi - I''m trying to get a multi-select box working. The form shows up fine, and I can select multiple items fine, but in the controller, the parameter shows up as a single string, instead of an array of values. Any ideas? The form: <%=select_tag "items", @items, :multiple => true :onchange => "this.form.onsubmit();"%> The form goes to function update_items in the controller, which fires just fine. But params[:items] is a single string value. Thanks in advance for any help. Dino
Frederick Cheung
2009-May-05 15:42 UTC
Re: select_tag with multiple set to true returns a String in params instead of array
On May 5, 4:07 pm, "dino d." <dinodorr...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hi - I''m trying to get a multi-select box working. The form shows up > fine, and I can select multiple items fine, but in the controller, the > parameter shows up as a single string, instead of an array of values. > Any ideas? > > The form: > > <%=select_tag "items", @items, :multiple => true :onchange => > "this.form.onsubmit();"%> > >use "items[]" for the first parameter ? (I though rails might do this automatically, obviously not) Fred>The form goes to function update_items in the controller, which fires > just fine. But params[:items] is a single string value. > > Thanks in advance for any help. > > Dino
dinoD
2009-May-05 15:59 UTC
Re: select_tag with multiple set to true returns a String in params instead of array
awesome, fixed. thanks fred. On May 5, 11:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 5, 4:07 pm, "dino d." <dinodorr...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > Hi - I''m trying to get a multi-select box working. The form shows up > > fine, and I can select multiple items fine, but in the controller, the > > parameter shows up as a single string, instead of an array of values. > > Any ideas? > > > The form: > > > <%=select_tag "items", @items, :multiple => true :onchange => > > "this.form.onsubmit();"%> > > use "items[]" for the first parameter ? (I though rails might do this > automatically, obviously not) > > Fred > > >The form goes to function update_items in the controller, which fires > > just fine. But params[:items] is a single string value. > > > Thanks in advance for any help. > > > Dino