kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
557 stars 302 forks source link

Correct GridView initialization for toggleData set to `false` #1011

Closed strtob closed 2 years ago

strtob commented 2 years ago

Hi,

I've updated to the latest 3.3.6.

Unfortunately, I have now a problem to open my forms in modal:

Exception 'TypeError' with message 'array_merge(): Argument #2 must be of type array, kartik\grid\SerialColumn given' 

in /var/www/html/assetor/vendor/yiisoft/yii2/grid/GridView.php:550

Stack trace:
#0 /var/www/html/assetor/vendor/yiisoft/yii2/grid/GridView.php(550): array_merge()
#1 /var/www/html/assetor/vendor/yiisoft/yii2/grid/GridView.php(288): yii\grid\GridView->initColumns()
#2 /var/www/html/assetor/vendor/kartik-v/yii2-grid/src/GridView.php(76): yii\grid\GridView->init()
#3 /var/www/html/assetor/vendor/yiisoft/yii2/base/BaseObject.php(109): kartik\grid\GridView->init()
#4 [internal function]: yii\base\BaseObject->__construct()
#5 /var/www/html/assetor/vendor/yiisoft/yii2/di/Container.php(420): ReflectionClass->newInstanceArgs()
#6 /var/www/html/assetor/vendor/yiisoft/yii2/di/Container.php(171): yii\di\Container->build()
#7 /var/www/html/assetor/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#8 /var/www/html/assetor/vendor/yiisoft/yii2/base/Widget.php(138): yii\BaseYii::createObject()
#9 /var/www/html/assetor/vendor/kartik-v/yii2-builder/src/TabularForm.php(478): yii\base\Widget::widget()
#10 /var/www/html/assetor/vendor/kartik-v/yii2-builder/src/TabularForm.php(214): kartik\builder\TabularForm->renderGrid()
#11 /var/www/html/assetor/vendor/yiisoft/yii2/base/Widget.php(141): kartik\builder\TabularForm->run()
#12 /var/www/html/assetor/views/company/_formCompanyAddress.php(106): yii\base\Widget::widget()
#13 /var/www/html/assetor/vendor/yiisoft/yii2/base/View.php(348): require('...')
#14 /var/www/html/assetor/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile()
#15 /var/www/html/assetor/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile()
#16 /var/www/html/assetor/views/company/_form.php(469): yii\base\View->render()
#17 /var/www/html/assetor/vendor/yiisoft/yii2/base/View.php(348): require('...')
#18 /var/www/html/assetor/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile()
#19 /var/www/html/assetor/vendor/yiisoft/yii2/web/View.php(221): yii\base\View->renderFile()
#20 /var/www/html/assetor/vendor/yiisoft/yii2/web/Controller.php(53): yii\web\View->renderAjax()
#21 /var/www/html/assetor/controllers/CompanyController.php(419): yii\web\Controller->renderAjax()
#22 [internal function]: app\controllers\CompanyController->actionUpdate()
#23 /var/www/html/assetor/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#24 /var/www/html/assetor/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams()
#25 /var/www/html/assetor/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction()
#26 /var/www/html/assetor/vendor/yiisoft/yii2/web/Application.php(104): yii\base\Module->runAction()
#27 /var/www/html/assetor/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Application->handleRequest()
#28 /var/www/html/assetor/web/index.php(13): yii\base\Application->run()
#29 {main}

Any ideas?

doston92 commented 2 years ago

In the composer.json file, change "kartik-v / yii2-grid": "dev-master" to "kartik-v / yii2-grid": "^ 3.1.6" and update composer

cufano commented 2 years ago

It seems that error disappear downgrading to 3.3.6, but now I get this new error:

Function name must be a string

in C:\wamp\www\unirep\vendor\kartik-v\yii2-builder\src\BaseForm.php

* @param string $id the input identifier.
     * @param array $settings the attribute settings.
     *
     * @return string the form input markup.
     * @throws InvalidConfigException
     * @throws Exception
     */
    protected function renderRawInput($attribute, &$id, $settings = [])
    {
        $notBs3 = !$this->isBs(3)();
        $type = ArrayHelper::getValue($settings, 'type', self::INPUT_TEXT);
        $i = strpos($attribute, ']');
        $attribName = $i > 0 ? substr($attribute, $i + 1) : $attribute;
        if (!in_array($type, static::$_validInputs)) {
            throw new InvalidConfigException(
                "Invalid input type '{$type}' configured for the attribute '{$attribName}'.'"
            );
        }
        $value = ArrayHelper::getValue($settings, 'value');
kartik-v commented 2 years ago

This is maybe not an issue with yii2-grid extension but how you are configuring the yii2-builder extension (TabularForm - as seen in the error stack). You may need to check the configuration of the widget and the attributes/columns (where somewhere you are not passing an array as expected).

cufano commented 2 years ago

True Kartik, I have downgraded yii2-builder to 1.6.7 and now it's running fine.

Thanks!

strtob commented 2 years ago

"kartik-v / yii2-grid": "dev-master" to "kartik-v / yii2-grid": "^ 3.1.6"

don't fix the problem. It seems that the grid component can't manage the serialcolumn option of TabularForm - maybe now a parameter has to be an array in the current dev version of grid

kartik-v commented 2 years ago

Thanks for the report. This has been fixed.

strtob commented 2 years ago

much appreciate, thanks Kartik!