public function run()
    {
        /* @var $model \yii\db\ActiveRecord */
        $model = new $this->modelClass();
        if ($this->scenario) {
            $model->setScenario($this->scenario);
        }
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            foreach ($model->toArray() as $key => $value) {
                //Yii::$app->settings->set($key, $value, $this->controller->module->id, $model->types[$key]);
                Yii::$app->settings->set($key, $value, $model->formName(), $model->types[$key]);
            }
            Yii::$app->getSession()->addFlash('success', Yii::t('system', 'Successfully saved settings.'));
            return $this->controller->redirect([$this->controller->action->id]);
        }
        foreach ($model->attributes() as $key) {
            $model->{$key} = Yii::$app->settings->get($key, $model->formName());
            //$model->{$key} = Yii::$app->settings->get($key, $this->controller->module->id);//直接使用模块ID
        }
        return $this->controller->render($this->viewName, ['model' => $model]);
    }
public function run()
    {
        /* @var $model \yii\db\ActiveRecord */
        $model = new $this->modelClass();
        if ($this->scenario) {
            $model->setScenario($this->scenario);
        }
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            foreach ($model->toArray() as $key => $value) {
                //Yii::$app->settings->set($key, $value, $this->controller->module->id, $model->types[$key]);
                Yii::$app->settings->set($key, $value, $model->formName(), $model->types[$key]);
            }
            Yii::$app->getSession()->addFlash('success', Yii::t('system', 'Successfully saved settings.'));
            return $this->controller->redirect([$this->controller->action->id]);
        }
        foreach ($model->attributes() as $key) {
            $model->{$key} = Yii::$app->settings->get($key, $model->formName());
            //$model->{$key} = Yii::$app->settings->get($key, $this->controller->module->id);//直接使用模块ID
        }
        return $this->controller->render($this->viewName, ['model' => $model]);
    }
public function run ( ) { /* @var $model \yii\db\ActiveRecord */ $ model = new $ this -> modelClass ( ) ; if ( $ this -> scenario ) { $ model -> setScenario ( $ this -> scenario ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { foreach ( $ model -> toArray ( ) as $ key => $ value ) { //Yii::$app->settings->set($key, $value, $this->controller->module->id, $model->types[$key]); Yii :: $ app -> settings -> set ( $ key , $ value , $ model -> formName ( ) , $ model -> types [ $ key ] ) ; } Yii :: $ app -> getSession ( ) -> addFlash ( 'success' , Yii :: t ( 'system' , 'Successfully saved settings.' ) ) ; return $ this -> controller -> redirect ( [ $ this -> controller -> action -> id ] ) ; } foreach ( $ model -> attributes ( ) as $ key ) { $ model -> { $ key } = Yii :: $ app -> settings -> get ( $ key , $ model -> formName ( ) ) ; //$model->{$key} = Yii::$app->settings->get($key, $this->controller->module->id);//直接使用模块ID } return $ this -> controller -> render ( $ this -> viewName , [ 'model' => $ model ] ) ; }
Render the settings form.
Render the settings form .