validateMultiple() публичный статический Метод

This method will validate every model. The models being validated may be of the same or different types.
public static validateMultiple ( array $models, array $attributeNames = null ) : boolean
$models array the models to be validated
$attributeNames array list of attribute names that should be validated. If this parameter is empty, it means any attribute listed in the applicable validation rules should be validated.
Результат boolean whether all models are valid. False will be returned if one or multiple models have validation error.
Пример #1
2
 /**
  * Anlegen eines Benutzers
  * 
  * @return \yii\web\View
  * @author KAS <*****@*****.**> 28.07.2015
  */
 public function actionCreate()
 {
     Yii::$app->view->params['headline'] = 'Benutzer anlegen';
     $model = new User();
     //----------------------------------------------------------------------
     $post = \Yii::$app->request->post();
     if ($model->load($post)) {
         $authArr = [];
         foreach ($post['Auth'] as $authData) {
             $authArr[] = new Auth($authData);
         }
         // Daten Validieren und Zuordnen -----------------------------------
         if (Model::loadMultiple($authArr, $post) && Model::validateMultiple($authArr)) {
             // aus den Auth Objekten machen wir arrays,
             // damit wir das in die Mongo speichern können
             $model->auth = array_map(function ($a) {
                 return $a->toArray();
             }, $authArr);
             // Speichern ---------------------------------------------------
             $model->save();
             // Benutzer benachrichtigen ------------------------------------
             \Yii::$app->session->setFlash('success', 'Benutzer wurde erfolgreich angelegt!', TRUE);
             // Neue Daten laden, da wir in den Models Veränderungen vornehmen
             $model->refresh();
         }
     }
     // Defaultwerte festlegen ----------------------------------------------
     $model->created_at = new \MongoDate();
     $model->updated_at = new \MongoDate();
     $model->role = "Normal";
     //----------------------------------------------------------------------
     return $this->render('create', ['model' => $model]);
 }
Пример #2
0
 public function update()
 {
     /**
      * @var $model SourceMessage
      */
     $model = $this->model;
     $model->initMessages();
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         Model::loadMultiple($model->messages, \Yii::$app->getRequest()->post());
         return Model::validateMultiple($model->messages);
         //return $rr->ajaxValidateForm($model);
     }
     if ($rr->isRequestPjaxPost()) {
         if (Model::loadMultiple($model->messages, \Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
             $model->saveMessages();
             //\Yii::$app->getSession()->setFlash('success', \Yii::t('app','Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
             } else {
                 return $this->redirect($this->indexUrl);
             }
         } else {
             //\Yii::$app->getSession()->setFlash('error', \Yii::t('app','Could not save'));
         }
     }
     return $this->render('_form', ['model' => $model]);
 }
Пример #3
0
 public function actionUser()
 {
     $model = new ModelInstallation();
     $model_user = new User();
     $model_user->setScenario('reset');
     $model->setScenario('username_installation');
     if ($model->load(Yii::$app->request->post()) && $model_user->load(Yii::$app->request->post()) && Model::validateMultiple([$model, $model_user])) {
         $model->titleInstallation();
         $role = Yii::$app->getModule("user")->model("Role");
         $model_user->role_id = $role::ROLE_ADMIN;
         $model_user->status = User::STATUS_ACTIVE;
         $model_user->create_time = date('Y-m-d H:i:s');
         $model_user->create_ip = Yii::$app->request->getUserHost();
         $model_user->api_key = Yii::$app->security->generateRandomString();
         $model_user->auth_key = Yii::$app->security->generateRandomString();
         $model_user->save();
         $profile_data = Yii::$app->getModule("user")->model("Profile");
         $profile_data->user_id = $model_user->id;
         $profile_data->full_name = $model_user->username;
         $profile_data->create_time = date('Y-m-d H:i:s');
         $profile_data->save(FALSE);
         return $this->refresh();
     }
     return $this->render('username_installation', ['model' => $model, 'model_user' => $model_user, 'form_title' => 'System configuration', 'page_info' => '']);
 }
Пример #4
0
 /**
  * Populates template and related models with the data, validates and saves
  * @param Template $template
  * @param array $data
  * @return bool
  */
 public function saveTemplate(Template $template, $data)
 {
     if ($template->load($data)) {
         $widgetAreas = $this->loadWidgetAreas($data);
         $widgets = $this->loadWidgets($data, 'Widgets');
         $valid = true;
         $valid = $template->validate() && $valid;
         $first = reset($widgetAreas);
         $valid = Model::validateMultiple($widgetAreas, array_diff($first->activeAttributes(), ['template_id'])) && $valid;
         $valid = Model::validateMultiple($widgets) && $valid;
         if ($valid && $template->save(false)) {
             if ($widgetAreas) {
                 foreach ($widgetAreas as $area) {
                     $area->template_id = $template->id;
                     if ($widgets) {
                         $this->setWidgets($area, $widgets);
                     }
                     $area->save();
                 }
             }
             return true;
         } else {
             if ($widgetAreas) {
                 $template->populateRelation('widgetAreas', $widgetAreas);
             }
             if ($widgets) {
                 $this->linkWidgets($widgetAreas, $widgets);
             }
         }
     }
     return false;
 }
 /**
  * Lists all models.
  * @return mixed
  */
 public function actionIndex()
 {
     $sourceLanguage = 'en-US';
     $languages = Yii::$app->yee->languages;
     $categories = MessageSource::getMessageCategories();
     unset($languages[$sourceLanguage]);
     $currentLanguage = Yii::$app->getRequest()->get('translation', NULL);
     $currentCategory = Yii::$app->getRequest()->get('category', NULL);
     if (!in_array($currentLanguage, array_keys($languages))) {
         $currentLanguage = NULL;
     }
     if (!in_array($currentCategory, array_keys($categories))) {
         $currentCategory = NULL;
     }
     if ($currentLanguage && $currentCategory) {
         Message::initMessages($currentCategory, $currentLanguage);
         $messageIds = MessageSource::getMessageIdsByCategory($currentCategory);
         $sourceTable = MessageSource::tableName();
         $messageTable = Message::tableName();
         $messages = Message::find()->andWhere(['IN', 'source_id', $messageIds])->andWhere(['language' => $currentLanguage])->indexBy('id')->all();
     } else {
         $messages = [];
     }
     if (User::hasPermission('updateTranslations') && Message::loadMultiple($messages, Yii::$app->request->post()) && Model::validateMultiple($messages)) {
         foreach ($messages as $message) {
             $message->save(false);
         }
         Yii::$app->session->setFlash('crudMessage', 'Your item has been updated.');
         return $this->refresh();
     }
     return $this->render('index', ['messages' => $messages, 'languages' => $languages, 'categories' => $categories, 'currentLanguage' => $currentLanguage, 'currentCategory' => $currentCategory]);
 }
Пример #6
0
 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param  integer $id The user id.
  * @return string|\yii\web\Response
  *
  * @throws NotFoundHttpException
  */
 public function actionUpdate($id)
 {
     // get role
     $role = Role::findOne(['user_id' => $id]);
     // get user details
     $user = $this->findModel($id);
     // only The Creator can update everyone`s roles
     // admin will not be able to update role of theCreator
     if (!Yii::$app->user->can('theCreator')) {
         if ($role->item_name === 'theCreator') {
             return $this->goHome();
         }
     }
     // load user data with role and validate them
     if ($user->load(Yii::$app->request->post()) && $role->load(Yii::$app->request->post()) && Model::validateMultiple([$user, $role])) {
         // only if user entered new password we want to hash and save it
         if ($user->password) {
             $user->setPassword($user->password);
         }
         // if admin is activating user manually we want to remove account activation token
         if ($user->status == User::STATUS_ACTIVE && $user->account_activation_token != null) {
             $user->removeAccountActivationToken();
         }
         $user->save(false);
         $role->save(false);
         return $this->redirect(['view', 'id' => $user->id]);
     } else {
         return $this->render('update', ['user' => $user, 'role' => $role]);
     }
 }
Пример #7
0
 public function actionWrong()
 {
     if (Yii::$app->getRequest()->getMethod() === 'OPTIONS') {
         return true;
     }
     $errors = [];
     $answers = Yii::$app->request->post('AnswersWrong');
     foreach ($answers['answers'] as $ans_id => $answer) {
         $modelArray[] = new AnswerWrong();
         $assign['AnswerWrong'][] = ['word_id' => $answer['id'], 'user_id' => Yii::$app->user->id, 'answer' => $answer['answer'], 'type' => $answer['type']];
     }
     if (Model::loadMultiple($modelArray, $assign) && Model::validateMultiple($modelArray)) {
         $errors = false;
         foreach ($modelArray as $model_answer) {
             if (!$model_answer->save()) {
                 $errors[] = Html::errorSummary($model_answer);
             }
         }
         if ($errors) {
             return $errors;
         }
     } else {
         return 'No record answers';
     }
 }
 public function actionSave($id)
 {
     // ---------------------- CHECK IS AJAX REQUEST ------------------------
     if (!Yii::$app->getRequest()->isAjax) {
         return $this->redirect(['/translations']);
     }
     // ------------------ SET JSON FORMAT FOR RESPONSE ---------------------
     // @see https://github.com/samdark/yii2-cookbook/blob/master/book/response-formats.md
     Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;
     // --------------------- SET DEFAULT RESPONSE --------------------------
     $response = array('status' => 'error', 'message' => Module::t('An unexpected error occured!'));
     // --------------------- SAVE TRANSLATION BY ID ------------------------
     // @see vendor\zelenin\yii2-i18n-module\controllers\DefaultController::actionUpdate
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         // clear translation cache
         if ($categories = AppHelper::getRequestParam('categories')) {
             foreach ($categories as $language => $category) {
                 Yii::$app->cache->delete(['yii\\i18n\\DbMessageSource', $category, $language]);
             }
         }
         $response['status'] = 'success';
         $response['message'] = 'Translation successfuly saved.';
         $response['params'] = AppHelper::getRequestParams();
     }
     return $response;
 }
Пример #9
0
 /**
  * @inheritDoc
  */
 protected function runTabular($models)
 {
     if ($success = Model::validateMultiple($models)) {
         foreach ($models as $model) {
             $model->save(false);
         }
     }
     return ['success' => $success, 'modeldata' => ArrayHelper::toArray($models)];
 }
Пример #10
0
 public function actionConfig()
 {
     $configs = Config::find()->indexBy('id')->all();
     if (Model::loadMultiple($configs, \Yii::$app->request->post()) && Model::validateMultiple($configs)) {
         foreach ($configs as $config) {
             $config->save(false);
         }
         return $this->redirect('config');
     }
     return $this->render('config', ['configs' => $configs]);
 }
Пример #11
0
 public function actionUpdate($id)
 {
     $flatPage = $this->findFlatPage($id);
     $translations = $flatPage->initializeTranslations();
     if ($flatPage->load(Yii::$app->request->post()) && Model::loadMultiple($translations, Yii::$app->request->post()) && Model::validateMultiple($translations) && $flatPage->save()) {
         $flatPage->saveTranslations($translations);
         Yii::$app->session->setFlash('success', Yii::t('app', "Page {$flatPage} updated successfully"));
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('flatPage', 'translations'));
 }
 public function actionUpdate($id)
 {
     $blogCategory = $this->findBlogCategory($id);
     $translations = $blogCategory->initializeTranslations();
     if ($blogCategory->load($_POST) && Model::loadMultiple($translations, $_POST) && Model::validateMultiple($translations) && $blogCategory->save()) {
         $blogCategory->saveTranslations($translations);
         Yii::$app->session->setFlash('success', Yii::t('app', "Blog Category {$blogCategory->name} updated successfully"));
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('blogCategory', 'translations'));
 }
Пример #13
0
 public function actionIndex()
 {
     $settings = Setting::find()->indexBy('key')->all();
     if (Model::loadMultiple($settings, Yii::$app->request->post()) && Model::validateMultiple($settings)) {
         foreach ($settings as $setting) {
             $setting->save(false);
         }
         Yii::$app->session->addFlash('success', 'تنظیمات با موفقیت ذخیره شد.');
         return $this->redirect('index');
     }
     return $this->render('index', ['settings' => $settings]);
 }
Пример #14
0
 /**
  * Performs batch updated of application configuration records.
  */
 public function actionIndex()
 {
     /* @var $configManager \yii2tech\config\Manager */
     $configManager = Yii::$app->get('configManager');
     $models = $configManager->getItems();
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         $configManager->saveValues();
         Yii::$app->session->setFlash('success', Yii::t('admin', 'Configuration updated.'));
         return $this->refresh();
     }
     return $this->render('index', ['models' => $models]);
 }
Пример #15
0
 /**
  * Отображение и сохранение конфигурации
  * @return string|\yii\web\Response
  */
 public function actionIndex()
 {
     $searchModel = new Config(["scenario" => ActiveRecord::SCENARIO_SEARCH]);
     $models = Config::find()->orderBy(["id" => SORT_DESC])->all();
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         foreach ($models as $setting) {
             $setting->save(false);
         }
         return $this->refresh();
     }
     return $this->render('index', ['models' => $models, "searchModel" => $searchModel]);
 }
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model->populateMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->request->post())) {
         $model->linkMessages();
         if (Model::validateMultiple($model->messages)) {
             Yii::$app->getSession()->setFlash('success', Module::t('Translation successfully updated'));
             return $this->redirect(['index']);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
 /**
  * @param integer $id
  * @return string|Response
  */
 public function actionUpdate($id)
 {
     /** @var SourceMessage $model */
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         Yii::$app->getSession()->setFlash('alert', ['body' => Module::t('Updated') . "<br/>" . Module::t('Go to list of') . " " . Html::a(Module::t('Not translated'), '/translations/index?SourceMessageSearch%5Bmessage%5D=&SourceMessageSearch%5Bcategory%5D=&SourceMessageSearch%5Bstatus%5D=2') . " " . Module::t('Or') . " " . Html::a(Module::t('All'), '/translations/index'), 'options' => ['class' => 'alert-success']]);
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  * @param integer $id
  * @return string|Response
  */
 public function actionUpdate($id)
 {
     /** @var SourceMessage $model */
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         Yii::$app->getSession()->setFlash('success', Module::t('Updated'));
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
Пример #19
0
 public function actionMail()
 {
     $this->layout = 'admin';
     // In @app/views/layouts
     $settings = Setting::find()->where(['category' => 'smtp'])->orderBy('id')->all();
     if (Model::loadMultiple($settings, Yii::$app->request->post()) && Model::validateMultiple($settings)) {
         /** @var \app\models\Setting $setting */
         foreach ($settings as $setting) {
             $setting->save(false);
         }
         // Show success alert
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The smtp server settings have been successfully updated.'));
     }
     return $this->render('mail', ['settings' => $settings]);
 }
Пример #20
0
 /**
  * Updates an existing View model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = ViewLang::findOne(['id' => $id, 'lang_id' => $i]);
     }
     if (Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content)) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/view']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
 /**
  * Creates a new EvauateScore model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($hospital_id, $group_id = null)
 {
     $group_id = $this->loadDefaultGroup($group_id);
     $models = $this->loadEvauateScoreModels($hospital_id, '2558', $group_id);
     $sumTheMust = $this->loadSummaryByUser($hospital_id, '2558', $group_id, 1);
     $sumTheBest = $this->loadSummaryByUser($hospital_id, '2558', $group_id, 2);
     $sumTheMustLevel1 = $this->loadSummaryLevel($hospital_id, '2558', $group_id, 1, 1);
     $sumTheBestLevel1 = $this->loadSummaryLevel($hospital_id, '2558', $group_id, 2, 1);
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         foreach ($models as $model) {
             $model->save(false);
         }
         return $this->redirect(['evauate-score/create', 'hospital_id' => $hospital_id, 'group_id' => $group_id]);
     }
     return $this->render('create', ['models' => $models, 'hospital_id' => $hospital_id, 'group_id' => $group_id, 'sumTheMust' => $sumTheMust, 'sumTheBest' => $sumTheBest]);
 }
Пример #22
0
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $lang = Lang::find()->all();
     foreach ($lang as $i) {
         $model_content[$i->code] = Message::findOne(['id' => $id, 'language' => $i->code]);
     }
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/message']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
Пример #23
0
 /**
  * Обрабатывает данные из формы и русет саму форму
  */
 public function actionIndex()
 {
     $rules = Titles::find()->indexBy('id')->all();
     $newRule = $this->newTitles();
     if ($newRule->load(Yii::$app->request->post()) and !empty($newRule->url) and !empty($newRule->title)) {
         $newRule->save();
         $newRule = $this->newTitles();
     }
     if (Model::loadMultiple($rules, Yii::$app->request->post()) && Model::validateMultiple($rules)) {
         foreach ($rules as $rule) {
             $rule->save(false);
             $rules = Titles::find()->indexBy('id')->all();
         }
     }
     return $this->render('index', ['rules' => $rules, 'newRule' => $newRule]);
 }
Пример #24
0
 /**
  * Creates a new Alumno model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $hoy = date('Y-m-d H:i:s');
     $perfil = new Perfil();
     $perfil->fecha_alta = $hoy;
     $alumno = new Alumno();
     $alumno->estado_id = EstadoAlumno::findOne(['descripcion' => EstadoAlumno::PREINSCRIPTO])->id;
     // Ver http://www.yiiframework.com/forum/index.php/topic/53935-subforms/page__gopid__248185#entry248185
     if ($perfil->load(Yii::$app->request->post()) && Model::validateMultiple([$perfil, $alumno])) {
         $perfil->save(false);
         $alumno->perfil_id = $perfil->id;
         $alumno->save(false);
         return $this->redirect(['view', 'id' => $alumno->id]);
     } else {
         return $this->render('create', ['model' => $alumno, 'perfil' => $perfil]);
     }
 }
Пример #25
0
 /**
  * регистрация магазина
  * @return type
  */
 public function actionShop()
 {
     $request = Yii::$app->request;
     $model = new \app\models\registration\ShopForm();
     $profile = new \app\models\Profile();
     if ($request->isAjax && $model->load($request->post()) && $profile->load($request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         $errors = \yii\helpers\ArrayHelper::merge(ActiveForm::validate($model), ActiveForm::validate($profile));
         return $errors;
     }
     if ($model->load($request->post()) && $profile->load($request->post()) && \yii\base\Model::validateMultiple([$model, $profile])) {
         $model->save($profile, $request->post('Url'));
         Yii::$app->session->setFlash('success', 'Регистрация успешна');
         return $this->goHome();
     }
     return $this->render('shop', ['user' => $model, 'profile' => $profile, 'url' => new Url()]);
 }
 /**
  * [通过POST数据载入附表的数据]
  * 该方法用于新建和修改时返回的POST数据
  * 新建时:需要创建数据来接受多条返回数据
  * 修改时:subdata已经是数组,所以直接能够被模型LOAD,而且如果不这样做,无法实现对isNewRecord的判断
  * @param  [post] [POST数组]
  * @return [null] [POST如果没有设置ReqItem]
  */
 public function loadSubData($post)
 {
     if (isset($post['ReqItem'])) {
         //如果是新建,则要组建数组
         if (!is_array($this->subData)) {
             $itemSum = count($post['ReqItem']);
             $reqItems = array();
             for ($i = 0; $i < $itemSum; $i++) {
                 $reqItems[] = new ReqItem();
             }
             $this->subData = $reqItems;
         }
         return Model::loadMultiple($this->subData, $post) && Model::validateMultiple($this->subData);
     } else {
         return null;
     }
 }
Пример #27
0
 /**
  * Updates an existing Kecamatan model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelProvinsi = $this->findModelProvinsi($model->kabupaten->id_prov);
     $modelProvinsi->scenario = 'DepDrop';
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $modelProvinsi->load(Yii::$app->request->post());
         if (Model::validateMultiple([$model, $modelProvinsi]) && $model->save()) {
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Your data kecamatan has been successfully updated'));
             return $this->redirect(['update', 'id' => $model->id_kec]);
         } else {
             Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Your data kecamatan failed to updated'));
         }
     }
     return $this->render('update', ['model' => $model, 'modelProvinsi' => $modelProvinsi]);
 }
Пример #28
0
 public function actionUpdate($id)
 {
     $blogPost = $this->findBlogPost($id);
     $translations = $blogPost->initializeTranslations();
     Model::loadMultiple($translations, $_POST);
     if ($blogPost->load($_POST) && Model::loadMultiple($translations, $_POST) && Model::validateMultiple($translations) && $blogPost->save()) {
         $blogPost->saveTranslations($translations);
         $blogPost->uploadedFeaturedImage = UploadedFile::getInstance($blogPost, 'uploadedFeaturedImage');
         if ($blogPost->saveFeaturedImageToDisk()) {
             Yii::$app->session->setFlash('success', Yii::t('app', 'Blog Post updated successfully'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'There was some error uploading the blog post Image'));
         }
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('blogPost', 'translations'));
 }
 /**
  * Updates an existing UserDlt model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelUser = $this->findModelUser($model->user_id);
     $modelUser->scenario = 'update';
     if ($model->load(Yii::$app->request->post()) && $modelUser->load(Yii::$app->request->post()) && Model::validateMultiple([$model, $modelUser])) {
         $modelUser->setPassword($modelUser->password);
         $modelUser->generateAuthKey();
         $modelUser->user_type = 2;
         if ($modelUser->save()) {
             $model->user_id = $modelUser->id;
             $model->save();
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'modelUser' => $modelUser]);
     }
 }
 /**
  * Updates an existing GradeOneForm model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($eid)
 {
     $models = $this::findGrade($eid);
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         $count = 0;
         foreach ($models as $model) {
             // populate and save records for each model
             if ($model->save()) {
                 // do something here after saving
                 $count++;
             }
         }
         Yii::$app->session->setFlash('success', 'Grade saved successfully!');
         return $this->render('view', ['models' => $models, 'eid' => $eid]);
     } else {
         return $this->render('update', ['models' => $models, 'eid' => $eid]);
     }
 }