[英]yii\base\ErrorException - Class 'app\controllers\EntryForm' not found
I just tried the Working with Forms tutorial on the "basic" version of Yii v 2.0.0. 我刚刚在Yii v 2.0.0的“基本”版本上尝试了使用表单教程。 I followed it step by step, but I guess something is wrong.
我一步一步地跟着它,但我想有些事情是错的。 I have the EntryForm model in place, SiteController has the actionEntry and both the views are there too.
我有EntryForm模型,SiteController有actionEntry,两个视图也在那里。
Error Trace: 错误跟踪:
1. in /usr/share/nginx/html/basic/controllers/SiteController.php at line 99
}
public function actionAbout()
{
return $this->render('about');
}
public function actionEntry()
{
$model = new EntryForm;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
// valid data received in $model
// do something meaningful here about $model ...
return $this->render('entry-confirm', ['model' => $model]);
} else {
// either the page is initially displayed or there is some validation error
2. yii\base\ErrorHandler::handleFatalError()
use app\\models\\EntryForm;
in SiteController.php solved it. 在SiteController.php解决了它。
The base namespace in SiteController.php is namespace app\\controllers; SiteController.php中的基本命名空间是命名空间app \\ controllers; .
。 So you can add use app\\models\\EntryForm;
所以你可以添加使用app \\ models \\ EntryForm; in the top of file or use $model = new \\app\\models\\EntryForm();
在文件顶部或使用$ model = new \\ app \\ models \\ EntryForm(); for direct select of class.
直接选择课程。
Managed to resolve my issue by generation a different table using Gii. 通过使用Gii生成不同的表来管理解决我的问题。 Then the auto generated class and used it on EnterForm.php
然后是自动生成的类,并在EnterForm.php上使用它
class EntryForm extends \\yii\\db\\ActiveRecord class EntryForm扩展\\ yii \\ db \\ ActiveRecord
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.