Example #1
0
 public function actionForm()
 {
     /* @var $name string*/
     /*  @var $email string */
     $form = new MyForm();
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $name = Html::encode($form->name);
         $email = Html::encode($form->email);
         $form->file = UploadedFile::getInstance($form, 'file');
         $form->file->saveAs('photo/' . $form->file->baseName . '.' . $form->file->extension);
     } else {
         $name = '';
         $email = '';
     }
     return $this->render('form', ['form' => $form, 'name' => $name, 'email' => $email]);
 }
Example #2
0
 public function actionMy()
 {
     $model = new MyForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         //model loaded and validated
         return $this->render('my-confirm', ['model' => $model]);
     } else {
         return $this->render('my', ['model' => $model]);
     }
 }