How To Insert Selected Item In Dropdownlist To Database In Yii

he guys help me

I need to insert sekected item in dropdown list to databse.how do I do that


 <?php echo $form->dropDownList($model,'type',array('prompt'=>'Select Type','1'=>'Phone','2'=>'E-mail'),array('class' => 'dropDownBox')); ?>

how to save database when user select what ever item in above dropdown.help me

thanx in advance

:)

Post it to an action!!

Can you give me sample code pls

what is your purpose?

If you use Gii tools, You don’t need any thing for saving. It generate all the codes you need it. It is so easy to make a huge of models, controllers, views and CRUD.

http://www.yiiframework.com/doc/guide/1.1/en/topics.gii

I need when user select phone option it shoul save in the database as phone and when user select telephone it shoud save in the database as telephone like wise .how to do that??

my contraller is like this


$userappliedjob->contact_method=$_POST['Applyjob']['type'];

Applyjob is Cform model

Example





echo CHtml::dropDownList('2','select_value',$data,array('prompt'=>'Move To Folder','class'=>'styled','submit'=>array('user/inbox','p'=>'1')));



note the ‘submit’

your exampke is not clear.anyway thanx.if someone can help me it is really appreciate




'submit'=>array('user/inbox')



here user/inbox is the action.

In the model file you define 2 constant for 1=mobile, 2=telephone etc.

And in the controller file:




switch($_POST['Applyjob']['type']){

    	case Model::mobile:

           	$userappliedjob->contact_method=Model::mobile;

           	break;

     	case Model::telephone:

           	$userappliedjob->contact_method=Model::telephone;

}