Form Not working in YII2

I am new to yii framework.

I have created a from like this. When i try to view the form in the browser like this http://localhost/basic/web/index.php?r=site/user i see a blank white page.

I checked the apache log, No errors logged.

Model

    <?php

    namespace appmodels;
    use Yii;
    use yiibaseModel;


    class UserForm extends Model
    {
        public $name;
        public $email;



        public function rules()
        {
            return [

                [['name', 'email'], 'required'],

                ['email', 'email'],

            ];
        }

    }

Controller

 public function actionUser(){

    $model = new UserForm;



    if ($model->load(yii::$app->request->post()) && $model->validate()) {
        echo "string";
        # code...
    }else{
        $this->render('userForm', ['model'=> $model]);
    }
}

Views/Sites

    <?php

    use yiihelpersHtml;
    use yiiwidgetsActiveForm;

    ?>

    <?php $form = ActiveForm::begin(); ?>
    <?= $form->field($model, 'name'); ?>
    <?= $form->field($model, 'email'); ?>

    <?= Html::submitButton('submit', ['class'=>'btn btn-success']); ?>

Can some one help me to fix this problem. Tnx.


Source: php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.