I am trying to save values from dropdown list into my table column role.
form
<?php echo CHtml::dropDownList('role', $model, $model->getRoleOptions(),
array('empty' => '---select role---'));
?>
model
public function getRoleOptions(){
return array('1' => 'Administrator', '2' => 'Center Administrator');
}
The value is not being saved. I have also declared role as safe.
Use activeDropDownList()
instead of dropDownList()
. If you get a dump from your post request, you probably see invalid $_POST value with dropDownList()
.