public function actionSelectFilters(int $categoryId, int $languageId, $id = null)
    {
        $category = Category::findOne($categoryId);
        if (empty($category)) throw new NotFoundHttpException();
        $filters = Filter::find()->where(['category_id' => $category->id])->all();
        $filter = (!empty($id)) ? Filter::findOne($id) : new Filter();

        if (Yii::$app->request->isPost) {
            $filter->load(Yii::$app->request->post());

            if ($filter->validate()) {
                $filter->category_id = $category->id;
                $filter->save();

                $this->trigger(self::EVENT_AFTER_EDIT_CATEGORY,
                    new CategoryEvent(['id' => $category->id]));

                Yii::$app->getSession()->setFlash('success', 'Data were successfully modified.');
                return $this->redirect(Yii::$app->request->referrer);
            }
        }

        return $this->render('save', [
            'viewName' => 'select-filters',
            'params' => [
                'languages' => Language::findAll(['active' => true]),
                'category' => $category,
                'selectedLanguage' => Language::findOne($languageId),
                'filters' => $filters,
                'newFilter' => new Filter(),
            ],
        ]);
    }
public function actionSelectFilters(int $categoryId, int $languageId, $id = null)
    {
        $category = Category::findOne($categoryId);
        if (empty($category)) throw new NotFoundHttpException();
        $filters = Filter::find()->where(['category_id' => $category->id])->all();
        $filter = (!empty($id)) ? Filter::findOne($id) : new Filter();

        if (Yii::$app->request->isPost) {
            $filter->load(Yii::$app->request->post());

            if ($filter->validate()) {
                $filter->category_id = $category->id;
                $filter->save();

                $this->trigger(self::EVENT_AFTER_EDIT_CATEGORY,
                    new CategoryEvent(['id' => $category->id]));

                Yii::$app->getSession()->setFlash('success', 'Data were successfully modified.');
                return $this->redirect(Yii::$app->request->referrer);
            }
        }

        return $this->render('save', [
            'viewName' => 'select-filters',
            'params' => [
                'languages' => Language::findAll(['active' => true]),
                'category' => $category,
                'selectedLanguage' => Language::findOne($languageId),
                'filters' => $filters,
                'newFilter' => new Filter(),
            ],
        ]);
    }
public function actionSelectFilters ( int $ categoryId , int $ languageId , $ id = null ) { $ category = Category :: findOne ( $ categoryId ) ; if ( empty ( $ category ) ) throw new NotFoundHttpException ( ) ; $ filters = Filter :: find ( ) -> where ( [ 'category_id' => $ category -> id ] ) -> all ( ) ; $ filter = ( ! empty ( $ id ) ) ? Filter :: findOne ( $ id ) : new Filter ( ) ; if ( Yii :: $ app -> request -> isPost ) { $ filter -> load ( Yii :: $ app -> request -> post ( ) ) ; if ( $ filter -> validate ( ) ) { $ filter -> category_id = $ category -> id ; $ filter -> save ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_CATEGORY , new CategoryEvent ( [ 'id' => $ category -> id ] ) ) ; Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , 'Data were successfully modified.' ) ; return $ this -> redirect ( Yii :: $ app -> request -> referrer ) ; } } return $ this -> render ( 'save' , [ 'viewName' => 'select-filters' , 'params' => [ 'languages' => Language :: findAll ( [ 'active' => true ] ) , 'category' => $ category , 'selectedLanguage' => Language :: findOne ( $ languageId ) , 'filters' => $ filters , 'newFilter' => new Filter ( ) , ] , ] ) ; }
Selects product filters for category

@param integer $id
@param integer $languageId
@param integer $categoryId
@return mixed
@throws Exception
Selects product filters for category