/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Metro::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'title_az', $this->title_az])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_en', $this->title_en]);
     return $dataProvider;
 }
Beispiel #2
0
echo $form->field($model, 'city_id')->dropDownList(ArrayHelper::map(City::find()->all(), 'id', 'title_az'), ['prompt' => '']);
?>

    <?php 
echo $form->field($model, 'district_id')->dropDownList(ArrayHelper::map(District::find()->all(), 'id', 'title_az'), ['prompt' => '', 'onchange' => '
                $.post( "/lost/location/' . '"+$(this).val(), function( data ) {
                    $( "select#found-street_id" ).html( data );
                });']);
?>

    <?php 
echo $form->field($model, 'street_id')->dropDownList(ArrayHelper::map(Street::find()->all(), 'id', 'title_az'), ['prompt' => '']);
?>

    <?php 
echo $form->field($model, 'metro_id')->dropDownList(ArrayHelper::map(Metro::find()->all(), 'id', 'title_az'), ['prompt' => '']);
?>

    <?php 
echo DateTimePicker::widget(['model' => $model, 'attribute' => 'date', 'language' => 'en', 'size' => 'ms', 'inline' => true, 'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd - HH:ii:ss P', 'todayBtn' => true]]);
?>
    

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
 /**
  * Finds the Metro model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Metro the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Metro::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }