/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Specialist::find(); $query->joinWith('statusgroup'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['statusgroup'] = ['asc' => ['status.name' => SORT_ASC], 'desc' => ['status.name' => SORT_DESC]]; $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_specialist' => $this->id_specialist, 'create_day' => $this->create_day, 'status' => $this->status]); $query->andFilterWhere(['like', 'name_specialist', $this->name_specialist])->andFilterWhere(['like', 'status.name', $this->statusgroup]); return $dataProvider; }
use yii\helpers\ArrayHelper; use backend\models\Specialist; use backend\models\Status; /* @var $this yii\web\View */ /* @var $model backend\models\SpecialistSick */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="specialist-sick-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id_specialist')->dropDownList(ArrayHelper::map(Specialist::find()->all(), 'id_specialist', 'name_specialist'), ['prompt' => 'Select specialist']); ?> <?php echo $form->field($model, 'name_sick')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'create_day')->textInput(); ?> <?php echo $form->field($model, 'status')->dropDownList(ArrayHelper::map(Status::find()->all(), 'id', 'name'), []); ?> <div class="form-group">