Submit array of objects to Controller

My view uses a model which has in it a property $skills which is an array.

The idea is that this array will be populated by a series of Objects of class ‘Skill’

In my view, I have a form that has a series of dropdowns like this:

$form->dropDownList($model, ‘skills’, $model->skills_options, array(‘empty’ => ‘Select…’, ‘class’=>‘formData’));

(one caveat, I’m building these select elements on demand via javascript, here is what they look like:

 <select id="SearchModel_skills" class="formData" name="SearchModel[skills]">

      <option value="">Select...</option>

      <option value="1"></option>



I can get one in the $_REQUEST vars like this:

Array ( [SearchModel] => Array ( [skills] => 1 ) [yt1] => Search )

But for any additional selects beyond the first, I only get the value for the last one in the request vars.

I thought that it could be because I need the select’s id to be something like SearchModel_skills[0] or even just skills[0], but I have tried both these approaches without success, so I must be missing something.


In .NET MVC, I would specify in the Model what the datatype of the array is (for example IList<Skill>) and the MVC magic would be able to populate it for me, but I’m not sure how to do something similar in Yii.

If I could even just manage to get all the values, I can cast them into the appropriate type via a loop in the Controller, I just need to get them there, and so far, all I can get is the last one in the series.

Any help would be appreciated.


I want to send back an array of objects on form submission to my controller and populate the view with them…how?