public function actionEntry()
 {
     $model = new EntryForm();
     // 获取 country 表的所有行并以 name 排序
     $countries = Country::find()->orderBy('name')->all();
     //print_r($countries);
     // 获取主键为 “US” 的行
     $country = Country::findOne('US');
     // 输出 “United States”
     //echo $country->name;
     // 修改 name 为 “U.S.A.” 并在数据库中保存更改
     //$country->name = 'U.S.A.';
     //$country->save();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // 验证 $model 收到的数据
         // 做些有意义的事 ...
         return $this->render('entry-confirm', ['model' => $model, 'countries' => $countries]);
     } else {
         // 无论是初始化显示还是数据验证错误
         //$this->renderFile('@app/views/myform/myform_header.php');
         //echo $this->render('myformheader');
         return $this->render('entry', ['model' => $model, 'countries' => $countries]);
     }
 }
 public function actionEntry()
 {
     $model = new EntryForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // данные в $model удачно проверены
         // делаем что-то полезное с $model ...
         return $this->render('entry-confrim', ['model' => $model]);
     } else {
         // либо страница отображается первый раз, либо есть ошибка в данных
         return $this->render('entry', ['model' => $model]);
     }
 }
Beispiel #3
0
 public function actionEntry()
 {
     $model = new EntryForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         return $this->render('entryConfirm', ['model' => $model]);
     } else {
         return $this->render('entry', ['model' => $model]);
     }
 }
Beispiel #4
0
 public function actionEntry()
 {
     $model = new EntryForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // validate data received in $model
         // do something
         return $this->render('entry-confirm', ['model' => $model]);
     } else {
         // either the page is initially displayed or there is some validation error
         return $this->render('entry', ['model' => $model]);
     }
 }