Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (is_callable($this->query)) {
         $this->query = call_user_func($this->query, $this->model);
     }
     if ($this->query instanceof ActiveQueryInterface) {
         if (!$this->labelAttribute) {
             throw new InvalidConfigException('Parameter "labelAttribute" is required');
         }
         $this->items = $this->query->all();
         foreach ($this->items as $i => $model) {
             $this->items[$i] = AdminHelper::resolveAttribute($this->labelAttribute, $model);
         }
     }
     if ($this->allowEmpty) {
         $this->items = ArrayHelper::merge([null => Yii::t('yii', '(not set)')], $this->items);
     }
     parent::init();
 }