public static function viaListFormat($model, $attribute, $options = [])
    {
        $relation = $model->getRelation($attribute);
        $relationClass = $relation->modelClass;
        $columns = Yii::$app->db->getTableSchema($relationClass::tableName())->columnNames;
        $titles = array_intersect(['title', 'name', 'username'], $columns);
        if (!$title = reset($titles)) {
            throw new \Exception(Yii::t('app', 'Relation does not have any title column'));
        }
        return array_merge([
            'attribute' => $attribute,
            'format' => 'raw',
            'value' => !$model->isNewRecord
                ? implode(', ', $relation->select($title)->column())
                : function ($data) use ($attribute, $title) {
                    return implode(', ', $data->getRelation($attribute)->select($title)->column());
                },
            'filter' => false,
            //'visible' => $model->isAttributeSafe($attribute),
        ], $options);
    }
public static function viaListFormat($model, $attribute, $options = [])
    {
        $relation = $model->getRelation($attribute);
        $relationClass = $relation->modelClass;
        $columns = Yii::$app->db->getTableSchema($relationClass::tableName())->columnNames;
        $titles = array_intersect(['title', 'name', 'username'], $columns);
        if (!$title = reset($titles)) {
            throw new \Exception(Yii::t('app', 'Relation does not have any title column'));
        }
        return array_merge([
            'attribute' => $attribute,
            'format' => 'raw',
            'value' => !$model->isNewRecord
                ? implode(', ', $relation->select($title)->column())
                : function ($data) use ($attribute, $title) {
                    return implode(', ', $data->getRelation($attribute)->select($title)->column());
                },
            'filter' => false,
            //'visible' => $model->isAttributeSafe($attribute),
        ], $options);
    }
public static function viaListFormat ( $ model , $ attribute , $ options = [ ] ) { $ relation = $ model -> getRelation ( $ attribute ) ; $ relationClass = $ relation -> modelClass ; $ columns = Yii :: $ app -> db -> getTableSchema ( $ relationClass :: tableName ( ) ) -> columnNames ; $ titles = array_intersect ( [ 'title' , 'name' , 'username' ] , $ columns ) ; if ( ! $ title = reset ( $ titles ) ) { throw new \ Exception ( Yii :: t ( 'app' , 'Relation does not have any title column' ) ) ; } return array_merge ( [ 'attribute' => $ attribute , 'format' => 'raw' , 'value' => ! $ model -> isNewRecord ? implode ( ', ' , $ relation -> select ( $ title ) -> column ( ) ) : function ( $ data ) use ( $ attribute , $ title ) { return implode ( ', ' , $ data -> getRelation ( $ attribute ) -> select ( $ title ) -> column ( ) ) ; } , 'filter' => false , //'visible' => $model->isAttributeSafe($attribute), ] , $ options ) ; }
Renders grid column for list value of via table data
@param ActiveRecord|bool $model
@param $attribute
@param array $options
@return array
@throws \Exception
Renders grid column for list value of via table data