public function actionCategory($categoryId) { $category = ProductCategory::findOne($categoryId); if (empty($category)) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($this->isAjax()) { $model = new Recipe(); $model->productCategoryId = $categoryId; return $this->renderPartial('@app/views/partials/_category-ingredients-dropdown-list', ['model' => $model, 'form' => ActiveForm::begin()]); } else { $params = Yii::$app->request->queryParams; $params['categoryId'] = $categoryId; $searchModel = new ProductRepository(); $dataProvider = $searchModel->search($params); return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'categoryName' => $category->name]); } }