public function relationList($relationName, $index = 'id', $name = null)
    {
        $model = $this->owner;
        /** @var ActiveRecord $class */
        $class = $model->getRelation($relationName)->modelClass;
        $item = new $class();
        /** @var \yii\db\ActiveQuery $relation */
        $relation = method_exists($item, 'search')
            ? $item->search([])
            : $class::find();
        $name = $name ? : static::getNameAttribute($model, $relationName);
        $result = $relation->select($name)
            ->orderBy($name)
            ->indexBy($index)
            ->column();
        return $result;
    }
public function relationList($relationName, $index = 'id', $name = null)
    {
        $model = $this->owner;
        /** @var ActiveRecord $class */
        $class = $model->getRelation($relationName)->modelClass;
        $item = new $class();
        /** @var \yii\db\ActiveQuery $relation */
        $relation = method_exists($item, 'search')
            ? $item->search([])
            : $class::find();
        $name = $name ? : static::getNameAttribute($model, $relationName);
        $result = $relation->select($name)
            ->orderBy($name)
            ->indexBy($index)
            ->column();
        return $result;
    }
public function relationList ( $ relationName , $ index = 'id' , $ name = null ) { $ model = $ this -> owner ; /** @var ActiveRecord $class */ $ class = $ model -> getRelation ( $ relationName ) -> modelClass ; $ item = new $ class ( ) ; /** @var \yii\db\ActiveQuery $relation */ $ relation = method_exists ( $ item , 'search' ) ? $ item -> search ( [ ] ) : $ class :: find ( ) ; $ name = $ name ? : static :: getNameAttribute ( $ model , $ relationName ) ; $ result = $ relation -> select ( $ name ) -> orderBy ( $ name ) -> indexBy ( $ index ) -> column ( ) ; return $ result ; }
Gets relation data list for dropdown
@param $relationName
@param string $index
@param null $name
@return array
@throws \Exception
Gets relation data list for dropdown