I am working in Yii2 Framework. In my model, I have class
class VisitorForm extends Model
{
public $station;
public $center;
public function rules()
{
return [
[['station', 'center'], 'required'],
];
}
}
and in my SiteController class I have the action method
public function actionVisitor()
{
$model = VisitorForm();
if($model->load(yii::$app->request->get())){
return $this->render('visitor', ['model' => $model]);
}
}
Also, I have included use app\models\VisitorForm;
.
Also in my view directory I have visitor.php
.
The above code is exactly similar to the EntryForm
code give in Yii2 Definitive Guide.
But I am getting the error while executing the code at line
$model = VistorForm(); // throwing error at this line
Call to undefined function app\controllers\VisitorForm()
I am not able to figure out, what is going wrong with me. at the line, where I create the model