Suppose I have a multiple select form on an initial page called
things[], and two target actions. The initial page submits to target
action 1, and target view 1 submits to target action 2.
When I submit the form on the initial page, I can access that set of
values in target action 1 and turn it into an array of objects by
doing something like this (assuming that the option values are object
ids, which they are in this case, but that’s not the question):
@things = []
params[:things].each { |thing| @things << Thing.find(thing) }
That works fine. My question is this - params[:things] is a list of
option values in some form. If I include this in target view 1:
<%= hidden_field_tag “things[]”, @params[:things] %>
The value of @params[:things] in target action 2 is the value text
concatenated together, which isn’t parseable as a distinct list the
way it was in target action 1.
In what form do the contents of the hidden variable need to be, in
order to make this work? Specifically, what should go in target view
1?
(Yes, I could probably store this in the session instead. Not my
question.)
Thanks.
–
- Adam
** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.everylastounce.com ]
[ Adam Fields (weblog) - - entertaining hundreds of millions of eyeball atoms every day ] … Blog
[ Adam Fields Resume ]… Experience
[ Adam Fields | Flickr ] … Photos
[ http://www.aquicki.com/wiki ]…Wiki
[ http://del.icio.us/fields ] … Links