Yii \ base \ ErrorException - class 'app \ controllers \ EntryForm' not found

I just tried the tutorial Working with Forms on the β€œBasic” Version of Yii v 2.0.0. I followed him step by step, but I think something is wrong. I have an EntryForm model in place, the SiteController has an actionEntry, and both have views too.

Error tracing:

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() 
+6
source share
3 answers

use app\models\EntryForm; in SiteController.php solved it.

+10
source

The base namespace in SiteController.php is the namespace application \ controllers ;. Thus, you can add the application \ models \ EntryForm; at the top of the file or use $ model = new \ app \ models \ EntryForm (); for direct class selection.

+1
source

It was possible to solve the problem of generating another table using Gii. Then an automatically generated class and used it on EnterForm.php

class EntryForm extends \ yii \ db \ ActiveRecord

0
source

Source: https://habr.com/ru/post/974869/


All Articles