On 13 July 2012 08:20, aldm alert
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> Hi,
>
> I was wondering how to access all option values in drop down list in
> rails params array.
> In params array only selected value is stored, so is there any way to
> access all options and selected value?
>
> One possibility is to create hidden field and fill it in javascript
> onsubmit event with all options and selected value and then access it
> hidden field in params array.
>
> Is there better solution for this?
There is no need to use javascript to populate the hidden field, just
populate it in the view when the view is generated. However, in the
request that generated the view there was presumably some information
that allowed the option values to be generated. Simply put whatever
is required to regenerate it in hidden fields and then use that to
regenerate the list in the controller. Another alternative would be
to save whatever is needed in the session.
Colin
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en-US.