/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Patrol::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemple #2
0
/* @var $model app\models\Scout */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="scout-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo Html::hiddenInput('where', $where);
?>

    <?php 
echo $form->field($model, 'patrolid')->dropDownList(ArrayHelper::map(Patrol::find()->all(), 'id', 'name'), ['prompt' => 'Choose a Patrol'])->label('Patrol');
?>

    <?php 
echo $form->field($model, 'name')->textInput();
?>

    <?php 
echo $form->field($model, 'phone')->textInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>