/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProgramRecord::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(['id' => $this->id, 'faculty_id' => $this->faculty_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function actionPrograms($id) { $first = 1; $count = ProgramRecord::find()->where(['faculty_id' => $id])->count(); $programs = ProgramRecord::find()->where(['faculty_id' => $id])->all(); if ($count > 0) { echo "<option value='" . $first . "'>" . 'select' . "</option>"; foreach ($programs as $program) { echo "<option value='" . $program->id . "'>" . $program->name . "</option>"; } } else { echo "<option>-</option>"; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($id) { $query = ProgramRecord::find()->where(['faculty_id' => $id]); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }