Yii blog Property "CRangeValidator.0" is not defined.异常
一、原因
$validator->$name=$value;
<?php echo $form->labelEx($model,'author'); ?>
问题原因:多了这行规则
array('status', 'in', 'range', array(0,1,2)),
二、现象
CException
C:\xampp\htdocs\yii\framework\validators\CValidator.php(189)
177 if(isset($params['skipOnError'])) 178 $validator->skipOnError=$params['skipOnError']; 179 } 180 else 181 { 182 $params['attributes']=$attributes; 183 if(isset(self::$builtInValidators[$name])) 184 $className=Yii::import(self::$builtInValidators[$name],true); 185 else 186 $className=Yii::import($name,true); 187 $validator=new $className; 188 foreach($params as $name=>$value) 189 $validator->$name=$value; 190 } 191 192 $validator->on=empty($on) ? array() : array_combine($on,$on); 193 $validator->except=empty($except) ? array() : array_combine($except,$except); 194 195 return $validator; 196 } 197 198 /** 199 * Validates the specified object. 200 * @param CModel $object the data object being validated 201 * @param array $attributes the list of attributes to be validated. Defaults to null,
Stack Trace
| #0 |
+
C:\xampp\htdocs\yii\framework\validators\CValidator.php(189): CComponent->__set("0", "range") |
| #1 |
+
C:\xampp\htdocs\yii\framework\base\CModel.php(286): CValidator::createValidator("in", Comment, "status", array("range", array(0, 1, 2))) |
| #2 |
+
C:\xampp\htdocs\yii\framework\base\CModel.php(260): CModel->createValidators() |
| #3 |
+
C:\xampp\htdocs\yii\framework\base\CModel.php(303): CModel->getValidators("author") |
| #4 |
+
C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(1237): CModel->isAttributeRequired("author") |
| #5 |
+
C:\xampp\htdocs\yii\framework\web\widgets\CActiveForm.php(562): CHtml::activeLabelEx(Comment, "author", array()) |
| #6 |
–
C:\xampp\htdocs\yii\blog\protected\views\comment\_form.php(11): CActiveForm->labelEx(Comment, "author")06 )); ?> 07 08 <p class="note">Fields with <span class="required">*</span> are required.</p> 09 10 <div class="row"> 11 <?php echo $form->labelEx($model,'author'); ?> 12 <?php echo $form->textField($model,'author',array('size'=>60,'maxlength'=>128)); ?> 13 <?php echo $form->error($model,'author'); ?> 14 </div> 15 16 <div class="row"> |
| #7 |
+
C:\xampp\htdocs\yii\framework\web\CBaseController.php(126): require("C:\xampp\htdocs\yii\blog\protected\views\comment\_form.php") |
| #8 |
+
C:\xampp\htdocs\yii\framework\web\CBaseController.php(95): CBaseController->renderInternal("C:\xampp\htdocs\yii\blog\protected\views/comment/_form.php", array("model" => Comment), true) |
| #9 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(869): CBaseController->renderFile("C:\xampp\htdocs\yii\blog\protected\views/comment/_form.php", array("model" => Comment), true) |
| #10 |
–
C:\xampp\htdocs\yii\blog\protected\views\post\view.php(39): CController->renderPartial("/comment/_form", array("model" => Comment))34 <?php echo Yii::app()->user->getFlash('commentSubmitted'); ?> 35 </div> 36 <?php else: ?> 37 <?php $this->renderPartial('/comment/_form',array( 38 'model'=>$comment, 39 )); ?> 40 <?php endif; ?> 41 42 </div><!-- comments --> |
| #11 |
+
C:\xampp\htdocs\yii\framework\web\CBaseController.php(126): require("C:\xampp\htdocs\yii\blog\protected\views\post\view.php") |
| #12 |
+
C:\xampp\htdocs\yii\framework\web\CBaseController.php(95): CBaseController->renderInternal("C:\xampp\htdocs\yii\blog\protected\views\post\view.php", array("model" => Post, "comment" => Comment), true) |
| #13 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(869): CBaseController->renderFile("C:\xampp\htdocs\yii\blog\protected\views\post\view.php", array("model" => Post, "comment" => Comment), true) |
| #14 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(782): CController->renderPartial("view", array("model" => Post, "comment" => Comment), true) |
| #15 |
–
C:\xampp\htdocs\yii\blog\protected\controllers\PostController.php(53): CController->render("view", array("model" => Post, "comment" => Comment))48 $comment=$this->newComment($post); 49 50 $this->render('view',array( 51 'model'=>$post, 52 'comment'=>$comment, 53 )); 54 } 55 56 /** 57 * Creates a new model. 58 * If creation is successful, the browser will be redirected to the 'view' page. |
| #16 |
+
C:\xampp\htdocs\yii\framework\web\actions\CInlineAction.php(49): PostController->actionView() |
| #17 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array("r" => "post/view", "id" => "3")) |
| #18 |
+
C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction) |
| #19 |
+
C:\xampp\htdocs\yii\framework\web\filters\CFilter.php(40): CFilterChain->run() |
| #20 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(1145): CFilter->filter(CFilterChain) |
| #21 |
+
C:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(CFilterChain) |
| #22 |
+
C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain) |
| #23 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(291): CFilterChain->run() |
| #24 |
+
C:\xampp\htdocs\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl")) |
| #25 |
+
C:\xampp\htdocs\yii\framework\web\CWebApplication.php(282): CController->run("view") |
| #26 |
+
C:\xampp\htdocs\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("post/view") |
| #27 |
+
C:\xampp\htdocs\yii\framework\base\CApplication.php(169): CWebApplication->processRequest() |
| #28 |
+
C:\xampp\htdocs\yii\blog\index.php(13): CApplication->run() |
2013-03-10 16:27:40 Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Yii Framework/1.1.13
浙公网安备 33010602011771号