Yii dropdownList为空导致错误

时间:2014-10-04 13:02:10

标签: php yii

$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'
));

如上面的代码中所解释的,当我评论行echo cHtml::dropDownList()时,表单在提交时效果很好。为什么以及如何解决它?

这是异常错误

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

0 个答案:

没有答案