Closed yanhuixie closed 6 years ago
I am not sure if I can completely understand why you are facing an issue. But I can clarify a few things. The theme
property is mandatory. If you set allowThemeSetting
to false
a hidden input will be rendered - which will ensure that a default value is always received.
So to summarize, the form submitted will always have at least one model attribute theme
supplied via POST irrespective of the allowPageSetting
, allowFilterSetting
, allowSortSetting
, allowThemeSetting
values. If you can help what else is your app code and config to reproduce... this can be checked.
Hi, @kartik-v , thanks for your reply. According to your reminder, we checked the config.php view, and maybe it's the answer. Let's see L75 of config.php, yes indeed it guarantees that at least "a hidden input will be rendered" will take effect. But I think it has a precondition, let's see L53, the $col must not equals 0. Our scenario is that we set four parameters to false at the same time, it means that $col will just equals 0, so eventually no field elements such as hidden input or textbox will be rendered and it causes the "$this->_model->load()" method failed at L515 in DynaGrid.php.
$cols = (int)$allowPageSetting + (int)$allowThemeSetting + (int)$allowFilterSetting + (int)$allowSortSetting;
$col = $cols == 0 ? 0 : 12 / $cols;
Hope this may help, thanks.
Ok ... thanks for the info... will check this.
Prerequisites
master
branch of yii2-dynagrid.Steps to reproduce the issue
Expected behavior and actual behavior
When I follow those steps, I see... there is no effect as expected hide/show setting
I was expecting... hide/show columns as set via personalize dialog
After some digging, we find out that if set "allowPageSetting allowThemeSetting allowFilterSetting allowSortSetting" at the same time, there will no any < input name="DynaGridConfig[xxx]" > element rendered into the form of personalize dialog, so L515 in DynaGrid.php "$this->_model->load(Yii::$app->request->post())" will return false and escape the following hide/show settins.
By the way, is "theme" necessary for this form? I also notice that a "required" validator is active for it in L92 DynaGridConfig.php.
Environment
Browsers
Operating System
Libraries
Isolating the problem