我只是研究 Yii 2 周,但我有一个项目。任务是使用 Yii Cactiveform 创建表单。但我得到这个错误:get_class() 期望参数 1 是对象,给定数组。这是我的控制器:
public function actionPersonal()
{
// Layout
$this->layout = '../layouts/news_style';
// Title
$this->pageTitle = Yii::app()->params['news_title'];
// Description
$this->pageDescription = Yii::app()->params['news_description'];
// Breadcrumbs
$this->breadcrumbs = array(
'My Profile' => array(),
);
$layout = $this->_layout();
return $this->render('my_profile', array(
'user' => Yii::app()->user->getUser(),
'postDoXe' => $layout['postDoXe'],
'newPosts' => $layout['newPosts'],
));
}
my_profile.php
<div class="input-group">
<?php echo $form->label(Yii::app()->user->getUser(),'username'); ?>
<?php echo $form->textField(Yii::app()->user->getUser(),'username'); ?>
</div>