/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TaskStatus::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
<?php $form = ActiveForm::begin(); ?> <?php $prjArr = Project::getProjectArr(); array_unshift($prjArr, ''); echo $form->field($model, 'projectID')->dropDownList($prjArr); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php $stArr = TaskStatus::getTaskStatusArr(); // array_unshift($stArr, ''); echo $form->field($model, 'status')->dropDownList($stArr); ?> <?php echo $form->field($model, 'priority')->textInput(); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'parentTask')->textInput(); ?>
/** * Finds the TaskStatus model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TaskStatus the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findTaskStatusModel($id) { if (($model = TaskStatus::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getTaskStatusArr() { $model = new TaskStatus(); $listData = ArrayHelper::map($model->find()->all(), 'id', 'name'); return $listData; }