2012-10-15 63 views
1

每個應用程序都有實例。當我嘗試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"> 
+0

請出示在InstanceController – Sergey

+0

您actionCreate通過堆棧跟蹤顯示調用表單時,打破了應用程序,不能字段驗證uuid,但它是自動填寫javascript – martinixs

+0

你有另一個模型'optional_note'是'Instance'模型的形式的一部分嗎?它看起來像試圖加載,而不是找到模型類。 – Stu

回答

3

參見:

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

的模型檢查規則

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

這是錯誤的,需要把列名相同的字符串

array('uuid, optional_note', ... 
+2

+1,很好的觀察 –

+0

公共函數規則(){ 返回數組( 數組('uuid','required'),... 甚至沒有必要在這個設置它並且不需要 – martinixs

+1

@martinixs,檢查'optional_note'的全部規則:在你保護的所有文件中查找字符串:'optional_note' – Sergey