I have a dropDownList set up in my view, and I would like to use it to change the current model instance being viewed, and I kind of have it working, but I’m stuck on how to pass the selected value into the ‘submit’ option for the dropDownList. If I manually enter a model id for ‘submit’, then the view refreshes and the new model is loaded, which is what I want it to do: so, how can I pass in the dropDownList’s selected value instead of a static value to make it useful. Here’s my dropDownList code:
if(count($mapsList) > 0)
echo "Change map: ";
echo CHtml::dropDownList('whichMap', 'id', $mapsList,
'submit'=>2// how to pass dropDownList's selected value, instead of 2
Well I ended up taking a somewhat different approach. I had to put the dropdownlist into a CHtml form and use onchange to submit the form. This is so I get the selected value in $_POST in my controller.
Next I had to modify my controller action to check for the form submission, and load the new model, and redirect to the view file for the new model. Here is my view file, and controller view action: