Php Yii dropdownList为空导致错误

Php Yii dropdownList为空导致错误,php,yii,Php,Yii,正如上面代码中所解释的,当我对行echo-cHtml::dropDownList()进行注释时,表单在提交时运行良好。为什么以及如何修复它 下面是异常错误 $criteria = new CDbCriteria(); $criteria->order = 'type_name'; $models = Type::model()->findAll($criteria); $list = CHtml::listData($models, 'typeid', 'type_name');

正如上面代码中所解释的,当我对行
echo-cHtml::dropDownList()
进行注释时,表单在提交时运行良好。为什么以及如何修复它

下面是异常错误

$criteria = new CDbCriteria();
$criteria->order = 'type_name';
$models = Type::model()->findAll($criteria);
$list = CHtml::listData($models, 'typeid', 'type_name');

echo CHtml::dropDownList('DataSkema[typeid]', $model->typeid, $list, array(
    'empty'=>'--Pilih Jenis Lokasi--', // this line causing error, when I comment it out the error is not showing
    'id'=>'type-drop',
    'class'=>'form-control'
));

如果使用
占位符更改
空的
键,会发生什么情况?另外,尝试在
$list
中再添加一个值。类似于
$list[0]='
我刚刚写了这个,它工作起来了
$form->dropDownList($model,'fk_branch_id',array(CHtml::listData(branchs::model()->findAll(array('condition'=>“branch_active='1','order'=>'branch'=>'branch_name ASC')),'pk_branch__id','branch_name')),array('empty'=>-=请选择一个=-','class'=>'form-control')))我意识到我遇到了一个带有字符串的整数列,postgresql问题。
CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "". The SQL statement executed was: SELECT * FROM "app_ref_location" "t" WHERE typeid=:typeid ORDER BY location_name