From [[https://www.youtube.com/watch?v=FOcmETyZsgA|Yii2 Lesson - 3 Forms in Yii]]\\
Create ''UserForm.php'' in models\\
<code>
<?php

 namespace app\models; 

 use yii\base\Model;
 
 class UserForm extends Model
 {
   public $name;
   public $email;
   
   public function rules()
   {
	return [
	 [['name','email'],'required'],
	 ['email','email'],
	];
   }
 }
</code>

In SiteController.php add
<code>
use app\models\UserForm;
</code>
plus section
<code>
    public function actionUser()
    {
     $model = new UserForm;
     if($model->load(Yii::$app->request->post()) && $model->validate())
      {
       Yii::$app->session->setFlash('success','You have entered the data correctly');
      }
     return $this->render('userForm',['model'=>$model]);  
    }
</code>
In views/site, create userForm with
<code>
<?php

 use yii\helpers\Html;
 use yii\widgets\ActiveForm;
 ?>
 <?php
  if (Yii::$app->session->hasFlash('success'))
   {
    echo Yii::$app->session->getFlash('success');
   }
 ?>
 <?php $form = ActiveForm::begin();?>
 <?= $form->field($model,'name'); ?>
 <?= $form->field($model,'email'); ?>
 <?= Html::submitButton('Submit',['class'=>'btn btn-success']); ?>
 <?php $form = ActiveForm::end(); ?>
</code>

Call site with ''http://site.local/web/index.php?r=site/user''\\
If you have entered correct data, the form will return with 'You have entered the data correctly' on top
