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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.