protected function findModel($id) { if (($model = Locations::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Locations::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['location_id' => $this->location_id]); $query->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'province', $this->province]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Locations::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; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Locations::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(['location_id' => $this->location_id]); $query->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'province', $this->province]); return $dataProvider; }
/* @var $model backend\models\Customers */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="customers-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'customer_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'zip_code')->widget(Select2::classname(), ['data' => ArrayHelper::map(Locations::find()->all(), 'location_id', 'zip_code'), 'language' => 'en', 'options' => ['placeholder' => 'Выберите zip_code', 'id' => 'zipCode'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'city')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'province')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
public function getLocationList() { $location = Locations::find()->all(); return ArrayHelper::map($location, 'id', 'name'); }
/* @var $model backend\models\Customers */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="customers-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'customer_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'zip_code')->widget(Select2::classname(), ['data' => ArrayHelper::map(Locations::find()->all(), 'location_id', 'zip_code'), 'options' => ['placeholder' => 'Select a Zip Code ...', 'id' => 'zipCode']]); ?> <?php echo $form->field($model, 'city')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'province')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
public function actionGetCityProvince($zipId) { $location = Locations::findOne($zipId); echo Json::encode($location); }
/* @var $model backend\models\Customers */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="customers-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'customer_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'zip_code')->widget(Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Locations::find()->all(), 'location_id', 'zip_code'), 'language' => 'en', 'options' => ['placeholder' => 'Select a Zip Code ...', 'id' => 'zipCode'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'city')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'province')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>