Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = \frontend\modules\doctors\models\Doctors::find()->orderBy('name');
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'number' => $this->number, 'price_initial' => $this->price_initial, 'price_secondary' => $this->price_secondary, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'phone', $this->phone]);
     return $dataProvider;
 }
Example #2
0
use frontend\modules\doctors\models\Doctors;
use frontend\modules\occupations\models\Occupations;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model frontend\models\Specialists */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="specialists-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$list = ArrayHelper::map(Doctors::find()->orderBy('name')->all(), 'id', 'name');
echo $form->field($model, 'doctor_id')->widget(Select2::classname(), ['data' => $list, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите врача ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
$list = ArrayHelper::map(Occupations::find()->orderBy('name')->all(), 'id', 'name');
echo $form->field($model, 'occupation_id')->widget(Select2::classname(), ['data' => $list, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите специальность ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Добавить') : Yii::t('app', 'Изменить'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php