Faryshta/yii2-enum

EnumColumn::enumClass is required even if model is the same?

Opened this issue · 1 comments

First of all thank you for a great set of components. Unfortunately, I have an issue around EnumColumn.

In GridView I must provide enumClass even if using the same model:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        [
            'attribute' => 'type',
            'class' => EnumColumn::class,
            'enumClass' => Command::class,
        ],

I am getting:

get_class(): Argument #1 ($object) must be of type object, null given

Given the fact that my model is the same:

return $this->render('index', [
    'dataProvider' => new ActiveDataProvider([
        'query' => Command::find(),
        'pagination' => ['pageSize' => 10],
        'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]],
    ]),
    'serverName' => Device::findOne(1)->name,
]);

Therefore, I am using the same model (Command) for both data provider and column class. So, according to your words:

optional, if you want to use a diferent class than the class of the current model 'enumClass' => Person::className()

This shouldn't be required. But, it is. At least on my side. I don't know, if this is a problem with my code or some bug in your code or some misunderstanding on my side.

Adding drop of the whole TypeError.pdf.