I can't pass the value of dropdownlist to database

I want to use dropdownlist to display the types,

<div class="row">

    &lt;?php echo CHtml::activeLabel(&#036;model,'typeId'); ?&gt;


    &lt;?php echo CHtml::dropDownList('typeId', 'typeId', 


                                   CHtml::listData(Type::model()-&gt;findAll(),'typeId','typeName'),


                                   array('prompt'=&gt;'Select a type',


                                   'id'=&gt;'typeId'));?&gt;  


&lt;/div&gt;

This is the controller:

foreach($_POST[‘Shipin’] as $name=>$value)

{

if(&#036;name){


	echo &#036;name;      //Nothing is output when it comes to name of dropdownlist


	echo '**';


	echo &#036;value;     //nothing is output when it comes to value of dropdownlist


	echo ' ';


    &#036;model-&gt;&#036;name=&#036;value;}

}echo $_POST[‘typeId’]; //here I can get the value of the dropdownlist

in the foreach, why can’t I get the name attribute of dropdownlist? thank u

3 questions.

[list=1][]what do you want to do ? more details.[]why so many “echo” raw calls in your “controller”.[*]why your controller don’t looks like any other standard and well known Yii Standard Action.[/list]

I guess he is testing the post data in his controller.

Since you loop $_POST[‘Shipin’], and you say you can get $_POST[‘typeId’] that means the dropdownlist is not correctly connected to the model. Your dropdown has a different model association (typeId) than the rest of your form. Change the first parameter in the dropdown to $model and see what happens.

Also further to Narretz answer, you’ll notice that you don’t have an input field named typeId but rather Shipin[typeId] and id’ed Shipin_typeId