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]); }
private function initializeItems() { $this->items = SettingModel::find()->indexBy('key')->all(); }