简体   繁体   English

yii \\ base \\ ErrorException - 找不到类'app \\ controllers \\ EntryForm'

[英]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.

相关问题 (Yii2) 类的对象 使用 shell 命令时,类 app\\models\\EntryForm 的对象无法转换为字符串 - (Yii2) Object of class Object of class app\models\EntryForm could not be converted to string when using shell command PHP致命错误– yii \\ base \\ ErrorException类'Dompdf \\ FrameDecorator \\ Page'未找到 - PHP Fatal Error – yii\base\ErrorException Class 'Dompdf\FrameDecorator\Page' not found ajax上的yii 2.0提交错误类'app \\ controllers \\ ActiveForm'未找到 - yii 2.0 on ajax submit error Class 'app\controllers\ActiveForm' not found 找不到消息“类'模型名称'的PHP致命错误'yii \\ base \\ ErrorException' - PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'Model Name' not found PHP公告– yii \\ base \\ ErrorException - PHP Notice – yii\base\ErrorException PHP致命错误– yii \\ base \\ ErrorException调用YII2中未定义的方法Yii :: app() - PHP Fatal Error – yii\base\ErrorException Call to undefined method Yii::app() in YII2 Yii -Class'frontend \\ controllers \\ UserForm'找不到错误 - Yii -Class 'frontend\controllers\UserForm' not found error ErrorException(E_ERROR)找不到类'app \\ Project' - ErrorException (E_ERROR) Class 'app\Project' not found 找不到类“ App \\ Http \\ Controllers \\ App \\ Category” - Class 'App\Http\Controllers\App\Category' not found PHP公告– yii \\ base \\ ErrorException(数组到字符串的转换)Yii - PHP Notice – yii\base\ErrorException (Array to string conversion) Yii
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM