我是新來的Yii,我創造降下來的工作。我面對錯誤,請給我建議。這裏他我下拉代碼對象無法轉換爲字符串錯誤警予
<?php
/* @var $this CreateproductController */
/* @var $model Createproduct */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'createproduct-form',
'method'=>'post',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.E0E0E0 EFF0F2
'enableAjaxValidation'=>false,
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row" style="background-color: #F7F7F7; height:30px;">
<?php echo $form->labelEx($model,'Product Type'); ?>                
<?php echo CHtml::dropDownList($model,'pr_name',$model->getTypeOptions()); ?>
<?php echo $form->error($model,'pr_type'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array('class'=>'button1')); ?>
</div>
<?php $this->endWidget(); ?>
</div>
的getTypeOptions()方法已經下面和恆定使用的方法內,並宣佈
const CAT_EMPTY=0;
const CAT_PHONE=1;
const CAT_ROUTERS=2;
const CAT_ACCESSORIES=3;
const CAT_SERVICES=4;
public function getTypeOptions()
{
return array(
self::CAT_EMPTY=>'Select_Category',
self::CAT_PHONE=>'Phones',
self::CAT_ROUTERS=>'Routers',
self::CAT_ACCESSORIES=>'Accessories',
self::CAT_SERVICES=>'Services',
);
}
幫我..
什麼是你所得到的錯誤? –
類Create Product的對象無法轉換爲字符串錯誤在yii..Createproduct我的模型類 – sonorita
這是什麼? '自:: CAT_EMPTY'?它是字符串嗎? –