public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Job::find(), 'pagination' => ['pageSize' => 1]]); $model = new DynamicModel(['search_keyword', 'search_location', 'search_type']); $model->addRule('search_type', 'integer')->addRule('search_location', 'string', ['max' => 128])->addRule('search_keyword', 'string', ['max' => 128]); if ($model->load(Yii::$app->request->post())) { switch ($model->search_type) { case Lookup::item_code('SearchType', 'Organizations'): return $this->redirect(['organization/index', 'search_keyword' => $model->search_keyword]); break; case Lookup::item_code('SearchType', 'Opportunities'): return $this->redirect(['job/index', 'search_keyword' => $model->search_keyword]); break; default: throw new NotFoundHttpException('Your search:' . $model->search_keyword); break; } } return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]); }