Dropdown Problem, Not Selecting The Value?

[font="Franklin Gothic Medium"]

Hi friends, my code is




<?php echo $form->labelEx($model,'type'); ?>

		<?php 

		$records = jobtype::model()->findAll();

		$list = CHtml::listData($records, 'type','type');

		echo CHtml::dropDownList($model,'type', $list, array('empty' => '(Select a name)'));

		?>

		<?php echo $form->error($model,'type'); ?>






the tables are like this

TABLE->jobtype

+--------------------+

|  id    |  type     |

|--------------------|

|   1    |  design   |

|   2    |  writing  |

---------------------- 


TABLE->company (which refers to $model here)

+-------------------------------+

| coid   |  type     |  co_name |

|--------------------|----------|

|   1    |  design   |   Abc    |

|   2    |  writing  |   XYZ    |

---------------------------------




I want to show the data from the "jobtype" table into the dropdown field,And after selecting the option from this dropdown menu, it should store the selected value in the company table(type column). Is the code is correct? please suggest me friends.

I’AM GETTING THIS ERROR “Object of class Company could not be converted to string”

[/font]

try this


echo CHtml::dropDownList($model,'type', $list+ array('empty' => '(Select a name)'));

I have solved it myself :rolleyes: , By putting the ‘Active’ before the dropdown list it is working fine. Anyhow thanks for your suggestion mate. :)