选择操作和奇怪的验证表单中的错误

时间:2012-10-15 01:51:00

标签: php yii

每个应用程序都有实例。当我尝试使用propirat方式来管理mananager时

'application/<slug:[\w+]+>/instance/create/' => 'instance/create',
'application/<slug:[\w+]+>/instance/<uuid:[\w0-9]+>/update/' => 'instance/update',

要打开链接,请以

的形式设置路径
$this->menu=array(
    array('label'=>'Create Instance', 'url'=>Yii::app()->createUrl('instance/create',  array('slug' => $model->application->slug, 'uuid' => $model->uuid))),
array('label'=>'Update Instance', 'url'=>Yii::app()->createUrl('instance/update', array('slug' => $model->application->slug, 'uuid' => $model->uuid))),

我收到错误

include(optional_note.php): failed to open stream: No such file or directory 

为了满足推荐,必须完成哪些文件?

更新

public function actionCreate()                                         
{                                                                      
$model=new Instance;                                                  
    $model->application_id = $this->_application->id;                  

// Uncomment the following line if AJAX validation is needed          
// $this->performAjaxValidation($model);                              

if(isset($_POST['Instance']))                                         
{                                                                     
    $model->attributes=$_POST['Instance'];                               
    if($model->save())                                                   
            $this->redirect(array('view','uuid'=>$model->uuid));                
}                                                                     

$this->render('create',array(                                         
    'model'=>$model,                                                     
));                                                                   
}

更新

现在出现奇怪的行为,获取以下字段参数

Stack Trace
#3 \yii-1.1.12.b600af\framework\base\CModel.php(285): CValidator::createValidator("optional_note", Instance, "uuid", array(0 => "length", "max" => 128)) 
#4 \yii-1.1.12.b600af\framework\base\CModel.php(259): CModel->createValidators()
#5 \yii-1.1.12.b600af\framework\base\CModel.php(302): CModel->getValidators("uuid")
#6 \yii-1.1.12.b600af\framework\web\helpers\CHtml.php(1197):  CModel->isAttributeRequired("uuid")
#7 \yii-1.1.12.b600af\framework\web\widgets\CActiveForm.php(563): CHtml::activeLabelEx(Instance, "uuid", array()) 
#8 \protected\views\instance\_form.php(25): CActiveForm->labelEx(Instance, "uuid")


 <?php echo $form->errorSummary($model); ?>
 <div class="row">
     <?php echo $form->labelEx($model,'uuid'); ?>
     <?php echo $form->textField($model,'uuid',array('size'=>60,'maxlength'=>128)); ?>
     <?php echo $form->error($model,'uuid'); ?>
 </div>
  <div class="row">

1 个答案:

答案 0 :(得分:3)

请参阅:

CValidator::createValidator("optional_note", Instance, "uuid", array(0 => "length", "max" => 128)), 

检查模型规则

array('uuid', 'optional_note' ...

这是错误的,需要将列名放在同一个字符串中

array('uuid, optional_note', ...