backend/controllers/PreferencesController.php
/**
     * Lists all Preferences models.
     * @return mixed
     */
Lists all Preferences models.
@return mixed
Lists all Preferences models . @return mixed
public function actionIndex()
    {
        $pref_list = Yii::$app->request->post('PreferencesSearch');
        if (is_array($pref_list)) {
            $tab = Preferences::CATEGORY_BASE;
            foreach ($pref_list as $key=>$val) {
                $pref = Preferences::findByKey($key);
                if ($pref) {
                    if ($pref->pref_value !== $val['pref_value']) {
                        $pref->pref_value = $val['pref_value'];
                        $tab = $pref->pref_category;
                        $pref->save(false);
                    }
                }
            }
            Yii::$app->session->setFlash('success', 'Все настройки успешно сохранены!');
            return $this->redirect(['index', 'tab' => $tab]);
        }
        return $this->render('index', [
            'preferences' => PreferencesSearch::getPrefArray(),
        ]);
    }
public function actionIndex ( ) { $ pref_list = Yii :: $ app -> request -> post ( 'PreferencesSearch' ) ; if ( is_array ( $ pref_list ) ) { $ tab = Preferences :: CATEGORY_BASE ; foreach ( $ pref_list as $ key => $ val ) { $ pref = Preferences :: findByKey ( $ key ) ; if ( $ pref ) { if ( $ pref -> pref_value !== $ val [ 'pref_value' ] ) { $ pref -> pref_value = $ val [ 'pref_value' ] ; $ tab = $ pref -> pref_category ; $ pref -> save ( false ) ; } } } Yii :: $ app -> session -> setFlash ( 'success' , 'Все настройки успешно сохранены!'); return $ this -> redirect ( [ 'index' , 'tab' => $ tab ] ) ; } return $ this -> render ( 'index' , [ 'preferences' => PreferencesSearch :: getPrefArray ( ) , ] ) ; }
Lists all Preferences models.
Lists all Preferences models .
//var_dump($pref_list);exit;