【问题标题】:yii Fatal error: Call to a member function getValidators() on a non-object in C:\xampp\htdocs\crudyii\framework\web\helpers\CHtml.php on line 2236yii 致命错误:在第 2236 行的 C:\xampp\htdocs\crudyii\framework\web\helpers\CHtml.php 中的非对象上调用成员函数 getValidators()
【发布时间】:2013-09-11 16:26:30
【问题描述】:

我正在 Yii 中尝试一个简单的程序

//这是我的模型

<?php
class Create extends CFormModel
{   

    public $a;
    public $b;
    public $c;
    public $d;
    public $e;
    public $f;

    public function rules() {
        return array(
            array('a, b, c, d, e, f', 'required'),
            array('a, b, c, d, e, f', 'numerical', 'integerOnly' => true),
        );
    }
}



?>


// this is the action in my controller

 public function actionCreate()
    {
                $model = new Create;
        $this->render('create',$model);
    }

// this is my view


    <?php
     $form=$this->beginWidget('CActiveForm'); 
     echo $form->textField($model,'a');
     $this->endWidget(); 
    ?>

我收到此错误..

致命错误:在非对象上调用成员函数 getValidators() 在 C:\xampp\htdocs\crudyii\framework\web\helpers\CHtml.php 上线 第2236章

提前致谢。

【问题讨论】:

  • 我们也需要您的查看代码。

标签: php yii


【解决方案1】:

试试

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-26
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多