/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CourseType::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['ct_id' => $this->ct_id]); $query->andFilterWhere(['like', 'ct_desc', $this->ct_desc]); return $dataProvider; }
<div class="course-form"> <?php $form = ActiveForm::begin(); ?> <?php // $form->field($model, 'crs_id')->textInput() ?> <?php if ($model->isNewRecord) { ?> <?php echo $form->field($model, 'crs_ct_id')->dropDownList(ArrayHelper::map(CourseType::find()->asArray()->all(), 'ct_id', 'ct_desc'), ['prompt' => '-Choose a Course Type-']); ?> <?php } else { ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Course Type', 'format' => 'text', 'value' => $model->crsCt->ct_desc]]]); ?> <?php } ?>