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().

activeDropDownList() method

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top