kartik-v / yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
http://demos.krajee.com/dynagrid
Other
74 stars 66 forks source link

yii\base\UnknownPropertyException: kartik\dynagrid\DynaGridDetail::moduleId #174

Closed leifox closed 6 years ago

leifox commented 6 years ago

Prerequisites

Steps to reproduce the issue

I have/had an old version running that has not yet included French translations. That's why I went and updated via composer to the current version. That results in an UnknownPropertyException, thus, none of my Dynagrids are running on my test machine anymore (Grids and everything else are running fine). I went on and had a look at the code and saw that you worked, amongst other things, on exactly that variable that PHP is complaining about now. On first glance it looks like moduleId is simply missing? See the yii error report (up to initiation of dynagrid) below.

Expected behavior and actual behavior

When I follow those steps, I see:

Exception Unknown Property – yii\base\UnknownPropertyException Setting unknown property: kartik\dynagrid\DynaGridDetail::moduleId

1. in /path_to_yii_root/vendor/yiisoft/yii2/base/Component.php at line 201
192193194195196197198199200201202203204205206207208209210

                $behavior->$name = $value;
                return;
            }
        }

        if (method_exists($this, 'get' . $name)) {
            throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
        }

        throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
    }

    /**
     * Checks if a property is set, i.e. defined and not null.
     * This method will check in the following order and act accordingly:
     *
     *  - a property defined by a setter: return whether the property is set
     *  - a property of a behavior: return whether the property is set
     *  - return `false` for non existing properties

2. in /path_to_yii_root/vendor/yiisoft/yii2/BaseYii.php at line 529 – yii\base\Component::__set('moduleId', 'dynagrid')
3. in /path_to_yii_root/vendor/yiisoft/yii2/base/Object.php at line 105 – yii\BaseYii::configure(kartik\dynagrid\DynaGridDetail, ['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
4. yii\base\Object::__construct(['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
5. in /path_to_yii_root/vendor/yiisoft/yii2/di/Container.php at line 381 – ReflectionClass::newInstanceArgs([['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...]])
6. in /path_to_yii_root/vendor/yiisoft/yii2/di/Container.php at line 156 – yii\di\Container::build('kartik\dynagrid\DynaGridDetail', [], ['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
7. in /path_to_yii_root/vendor/yiisoft/yii2/BaseYii.php at line 348 – yii\di\Container::get('kartik\dynagrid\DynaGridDetail', [], ['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
8. in /path_to_yii_root/vendor/yiisoft/yii2/base/Widget.php at line 136 – yii\BaseYii::createObject(['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
9. in /path_to_yii_root/vendor/kartik-v/yii2-dynagrid/DynaGrid.php at line 1143 – yii\base\Widget::widget(['id' => 'dynagrid-elevators-filter-modal', 'model' => kartik\dynagrid\models\DynaGridSettings, 'moduleId' => 'dynagrid', 'toggleButton' => ['label' => '<i class='glyphicon glyphicon-fi...', 'title' => 'filter speichern / bearbeiten', 'data-pjax' => false, 'class' => 'btn btn-default'], ...])
1137113811391140114111421143114411451146114711481149

                    'submitMessage' => $this->submitMessage,
                    'deleteMessage' => $this->deleteMessage,
                    'messageOptions' => $this->messageOptions,
                    'deleteConfirmation' => $this->deleteConfirmation,
                    'isPjax' => $this->_isPjax,
                    'pjaxId' => $this->_pjaxId,
                    'krajeeDialogSettings' => $this->krajeeDialogSettings,
                ]
            );
        }
        if ($this->showSort) {
            $this->setToggleButton(DynaGridStore::STORE_SORT);
            $model->category = DynaGridStore::STORE_SORT;

10. in /path_to_yii_root/vendor/kartik-v/yii2-dynagrid/DynaGrid.php at line 533 – kartik\dynagrid\DynaGrid::initGrid()
527528529530531532533534535536537538539

        $this->configureColumns();
        $this->applyGridConfig();
        $this->_isPjax = ArrayHelper::getValue($this->gridOptions, 'pjax', false);
        if ($this->_isPjax) {
            $this->gridOptions['pjaxSettings']['options']['id'] = $this->_pjaxId;
        }
        $this->initGrid();
    }

    /**
     * Can the column be reordered
     *
     * @param mixed $column

11. in /path_to_yii_root/vendor/kartik-v/yii2-dynagrid/DynaGrid.php at line 431 – kartik\dynagrid\DynaGrid::initWidget()
425426427428429430431432433434435436437

    /**
     * @inheritdoc
     */
    public function run()
    {
        $this->initWidget();
        echo Html::tag('div', GridView::widget($this->gridOptions), $this->options);
        parent::run();
    }

    /**
     * Initialize the module based on module identifier

12. in /path_to_yii_root/vendor/yiisoft/yii2/base/Widget.php at line 139 – kartik\dynagrid\DynaGrid::run()
13. in /path_to_yii_root/frontend/views/elevator/indexList.php at line 30 – yii\base\Widget::widget(['columns' => [['class' => 'kartik\grid\DataColumn', 'attribute' => 'Action', 'label' => 'Aktion', 'format' => 'raw', ...], 'description', 'notes', 'elevator_no'], 'storage' => 'db', 'theme' => 'simple-bordered', 'showSort' => false, ...])
24252627282930313233343536

?>
<div>
    <?php

     echo DynaGrid::widget([
        'columns' => $columns,
        'storage' => DynaGrid::TYPE_DB,
        'theme' => 'simple-bordered',
        'showSort' => false,
        'showPersonalize' => true,
        'gridOptions' => [
            'dataProvider' => $dataProvider,

Environment

Libraries

Isolating the problem

kartik-v commented 6 years ago

This is happening because you do not have correct latest release of all dependencies. Ensure you have the latest release of yii2-krajee-base as well. It should be done automatically if you update all packages by composer rather than manually copying files.

leifox commented 6 years ago

Thank you for the promt reply!

I updated composer again and it updated the dependencies as well, so everything fine now.

Thank you for all your work 👍

leifox commented 6 years ago

Btw: How can I contribute correct translations for german/french? There are some minor mistakes...

kartik-v commented 6 years ago

Btw: How can I contribute correct translations for german/french? There are some minor mistakes...

You can submit a pull request on this repo for your translations update. I will merge them.