/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Raion::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(['raion_id' => $this->raion_id]);
     $query->andFilterWhere(['like', 'raion_name', $this->raion_name]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRaion()
 {
     return $this->hasOne(Raion::className(), ['raion_id' => 'raion_id']);
 }
 /**
  * Finds the Raion model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Raion the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Raion::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(Raion::className(), ['user_id' => 'user_id']);
 }
Beispiel #5
0
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать район', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

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


    <?php 
echo $form->field($model, 'Raion')->dropDownList(ArrayHelper::map(Raion::find()->all(), 'raion_id', 'raion_name'), ['prompt' => 'Выберите область']);
?>

    <?php 
echo $form->field($model, 'raion_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'raion_id', 'raion_name', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>