/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Region::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemple #2
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\modules\unicred\questionlist\models\Region;
use app\modules\unicred\questionlist\models\Users;
use app\modules\unicred\questionlist\models\Office;
/* @var $this yii\web\View */
/* @var $model app\modules\unicred\questionlist\models\Users */
/* @var $form yii\widgets\ActiveForm */
/* @var $usersRoles array */
$offices = ArrayHelper::map(Office::find()->all(), 'id', 'name');
$regions = ArrayHelper::map(Region::find()->all(), 'id', 'name');
?>

<div class="users-offices-form">

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

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

    <?php 
echo $form->field($model, "office_id")->dropDownList($offices, [$model->office_id => ['selected' => 'selected'], 'prompt' => 'Выберите ..']);
?>

    <?php