/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::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, 'status' => $this->status, 'created' => $this->created, 'responsible_user' => $this->responsible_user]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Finds the Projects model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Projects the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Project::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getProjectArr() { $listData = ArrayHelper::map(Project::findAll(['1=1']), 'id', 'name'); return $listData; }
public function getProjectName() { return Project::getProjectName($this->projectID); }
use yii\jui\DatePicker; use app\modules\cubicProject\models\Project; use app\modules\cubicProject\models\TaskStatus; /* @var $this yii\web\View */ /* @var $model app\modules\cubicProject\models\Tasks */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="tasks-form"> <?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