php - How can solve fetal error while adding action? -
how can remove fatal error applying following code controller.php
public function actionuser() { $model= new userform(); if($model->load(yii::$app->request->post()) && $model->validate()) { //lates wirite later }else{ return $this->render('userform',['model'=>$model]); }
and userform models code:
class userform extends model { public $name; public $email; public function rules() { return[ [['name','email'],'required'], ['email','email'], ]; } }
and views code:
use yii\helpers\html; use yii\widgets\activeforms; $form=activeform::begin(); echo $form->field($model,'name'); echo $form->field($model,'email'); echo html::submitbutton('submit',['class'=>'btn btn-success']);
Comments
Post a Comment