/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Street::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, 'district_id' => $this->district_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; }
public function actionLocation($id) { $countStreet = Street::find()->where(['district_id' => $id])->count(); $streets = Street::find()->where(['district_id' => $id])->all(); if ($countStreet > 0) { foreach ($streets as $street) { echo "<option value='" . $street->id . "'>" . $street->title_az . "</option>"; } } else { //echo "<option> Not have sub category </option>"; } }
echo $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(Cats::find()->all(), 'id', 'title_az'), ['prompt' => '']); ?> <?php 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]); ?>
<i class="fa fa-angle-down"></i> </div> <div class="select"> <?php echo $form->field($model, 'district_id')->dropDownList(ArrayHelper::map(District::find()->all(), 'id', 'title_az'), ['prompt' => Yii::t('yii', 'choosedistrict'), 'onchange' => ' $.get( "/lost/location/' . '"+$(this).val(), function( data ) { $( "select#lost-street_id" ).html( data ); });'])->label(false); ?> <i class="fa fa-angle-down"></i> </div> <div class="select"> <?php echo $form->field($model, 'street_id')->dropDownList(ArrayHelper::map(Street::find()->all(), 'id', 'title_az'), ['prompt' => Yii::t('yii', 'choosestreet')])->label(false); ?> <i class="fa fa-angle-down"></i> </div> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <strong><?php echo Yii::t('yii', 'Add photo of the item you are looking for'); ?> </strong> </h4>