我正在尝试将下拉列表中的值保存到我的表列角色中。
形式
<?php echo CHtml::dropDownList('role', $model, $model->getRoleOptions(),
array('empty' => '---select role---'));
?>
型
public function getRoleOptions(){
return array('1' => 'Administrator', '2' => 'Center Administrator');
}
未保存该值。我也宣布角色是安全的。
使用 activeDropDownList()
而不是 dropDownList()
。如果从 post 请求中获取转储,则可能会看到无效的 $_POST 值,其中包含 dropDownList()
。
activeDropDownList() 方法