public static function getDropDownItems($query)
    {
        if ($query instanceof ActiveQuery) {
            $query->defaultOrder();
        }

        /** @var \yii\db\ActiveRecord|\netis\rbac\AuthorizerBehavior $model */
        $model = new $query->modelClass;

        $fields = $model::primaryKey();
        if (($labelAttributes = $model->getBehavior('labels')->attributes) !== null) {
            $fields = array_merge($model::primaryKey(), $labelAttributes);
        }

        $flippedPrimaryKey = array_flip($model::primaryKey());
        return ArrayHelper::map(
            $query->from($model::tableName() . ' t')->all(),
            function ($item) use ($fields, $flippedPrimaryKey) {
                /** @var \netis\crud\db\ActiveRecord $item */
                return Action::exportKey(array_intersect_key($item->toArray($fields, []), $flippedPrimaryKey));
            },
            function ($item) use ($fields) {
                /** @var \netis\crud\db\ActiveRecord $item */
                $data = $item->toArray($fields, []);
                return $data['_label'];
            }
        );
    }
public static function getDropDownItems($query)
    {
        if ($query instanceof ActiveQuery) {
            $query->defaultOrder();
        }

        /** @var \yii\db\ActiveRecord|\netis\rbac\AuthorizerBehavior $model */
        $model = new $query->modelClass;

        $fields = $model::primaryKey();
        if (($labelAttributes = $model->getBehavior('labels')->attributes) !== null) {
            $fields = array_merge($model::primaryKey(), $labelAttributes);
        }

        $flippedPrimaryKey = array_flip($model::primaryKey());
        return ArrayHelper::map(
            $query->from($model::tableName() . ' t')->all(),
            function ($item) use ($fields, $flippedPrimaryKey) {
                /** @var \netis\crud\db\ActiveRecord $item */
                return Action::exportKey(array_intersect_key($item->toArray($fields, []), $flippedPrimaryKey));
            },
            function ($item) use ($fields) {
                /** @var \netis\crud\db\ActiveRecord $item */
                $data = $item->toArray($fields, []);
                return $data['_label'];
            }
        );
    }
public static function getDropDownItems ( $ query ) { if ( $ query instanceof ActiveQuery ) { $ query -> defaultOrder ( ) ; } /** @var \yii\db\ActiveRecord|\netis\rbac\AuthorizerBehavior $model */ $ model = new $ query -> modelClass ; $ fields = $ model :: primaryKey ( ) ; if ( ( $ labelAttributes = $ model -> getBehavior ( 'labels' ) -> attributes ) !== null ) { $ fields = array_merge ( $ model :: primaryKey ( ) , $ labelAttributes ) ; } $ flippedPrimaryKey = array_flip ( $ model :: primaryKey ( ) ) ; return ArrayHelper :: map ( $ query -> from ( $ model :: tableName ( ) . ' t' ) -> all ( ) , function ( $ item ) use ( $ fields , $ flippedPrimaryKey ) { /** @var \netis\crud\db\ActiveRecord $item */ return Action :: exportKey ( array_intersect_key ( $ item -> toArray ( $ fields , [ ] ) , $ flippedPrimaryKey ) ) ; } , function ( $ item ) use ( $ fields ) { /** @var \netis\crud\db\ActiveRecord $item */ $ data = $ item -> toArray ( $ fields , [ ] ) ; return $ data [ '_label' ] ; } ) ; }
Get drop down list items using provided Query.

__WARNING__: This method does not append authorized conditions to query and you need append those if needed.

@param \yii\db\ActiveQuery $query

@return array
Get drop down list items using provided Query .