Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct GridView initialization for toggleData set to false #1011

Closed
strtob opened this issue Nov 15, 2021 · 7 comments
Closed

Correct GridView initialization for toggleData set to false #1011

strtob opened this issue Nov 15, 2021 · 7 comments
Labels

Comments

@strtob
Copy link

strtob commented Nov 15, 2021

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
Copy link

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

@cufano
Copy link

cufano commented Nov 19, 2021

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
Copy link
Owner

kartik-v commented Nov 19, 2021

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
Copy link

cufano commented Nov 19, 2021

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

Thanks!

@strtob
Copy link
Author

strtob commented Nov 19, 2021

"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 kartik-v added the bug label Nov 19, 2021
@kartik-v kartik-v reopened this Nov 19, 2021
@kartik-v kartik-v changed the title after update to: 3.3.6: 'TypeError' with message 'array_merge(): Argument #2 must be of type array, kartik\grid\SerialColumn given' Correct GridView initialization for toggleData set to false Nov 19, 2021
@kartik-v
Copy link
Owner

Thanks for the report. This has been fixed.

@strtob
Copy link
Author

strtob commented Nov 19, 2021

much appreciate, thanks Kartik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants