Learning Yii : Working with Forms

Hi :)

On your web site ,

www.yiiframework.com / doc-2.0 / guide-start-forms.html ,

you wrote the second code as like as :


$model = new EntryForm();

$model->name = 'Qiang';

$model->email = 'bad';

if ($model->validate()) {

    // Good!

} else {

    // Failure!

    // Use $model->getErrors()


but I don’t know which file I must put it.

Could you write me which file and which directory ? :unsure:

I followed the explanation except this step like this :

Creating a Model - > .../models/EntryForm.php

Creating an Action - > .../controllers/SiteController.php

Creating Views - > .../views/site/entry-confirm.php

And when I tried it ( / web / index.php?r=site%2Fentry), I have a this message :


Class ‘app\controllers\EntryForm’ not found

Thanks :)

That code is just an example, you wouldn’t use it like that in your web app. You only need what’s in the following paragraph: http://www.yiiframework.com/doc-2.0/guide-start-forms.html#creating-action

Most likely this is missing:

use app\models\EntryForm;

Thanks Patrick :rolleyes: