Closed arthurkushman closed 7 years ago
What is your $attributes
variable?
What is what? Content or You need the print_r here? It is an array 100%, because there is a check with is_array($attributes)
code:
if (empty($attributes) === false && is_array($attributes)) {
echo \yii\grid\GridView::widget(
[
'layout' => "{items}\n{pager}",
'dataProvider' => $list,
'columns' => $attributes
]
);
}
It might be an array itself but what does it contain?
That's what I've talked about, ok - here it is:
Array ( [0] => Array ( [class] => yii\grid\SerialColumn ) [attribute] => errorContainedPercent [format] => raw [content] => Closure Object ( [this] => yii\web\View Object ( [assetBundles] => Array ( [app\views\statistic\StatisticAsset] => app\views\statistic\StatisticAsset Object ( [sourcePath] => /Users/arthur/www/qcs/views/statistic/assets [css] => Array ( [0] => style.css ) [js] => Array ( ) [basePath] => /Users/arthur/www/qcs/web/assets/a3dfc438 [baseUrl] => /assets/a3dfc438 [depends] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [app\components\widgets\FilterWidgetAsset] => app\components\widgets\FilterWidgetAsset Object ( [sourcePath] => /Users/arthur/www/qcs/components/widgets/assets [css] => Array ( [0] => filter-widget-style.css ) [basePath] => /Users/arthur/www/qcs/web/assets/c68041a4 [baseUrl] => /assets/c68041a4 [depends] => Array ( ) [js] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [yii\web\JqueryAsset] => yii\web\JqueryAsset Object ( [sourcePath] => /Users/arthur/www/qcs/vendor/bower/jquery/dist [js] => Array ( [0] => jquery.js ) [basePath] => /Users/arthur/www/qcs/web/assets/1ca7002f [baseUrl] => /assets/1ca7002f [depends] => Array ( ) [css] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [kartik\date\DatePickerAsset] => kartik\date\DatePickerAsset Object ( [depends] => Array ( [0] => yii\web\JqueryAsset [1] => yii\bootstrap\BootstrapAsset ) [js] => Array ( [0] => js/bootstrap-datepicker.min.js [1] => js/datepicker-kv.min.js [2] => js/locales/bootstrap-datepicker.ru.min.js [3] => js/locales/bootstrap-datepicker.ru.min.js ) [css] => Array ( [0] => css/bootstrap-datepicker3.min.css [1] => css/datepicker-kv.min.css ) [sourcePath] => /Users/arthur/www/qcs/vendor/kartik-v/yii2-widget-datepicker/assets [basePath] => /Users/arthur/www/qcs/web/assets/15e73389 [baseUrl] => /assets/15e73389 [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [yii\bootstrap\BootstrapAsset] => yii\bootstrap\BootstrapAsset Object ( [sourcePath] => /Users/arthur/www/qcs/vendor/bower/bootstrap/dist [css] => Array ( [0] => css/bootstrap.css ) [basePath] => /Users/arthur/www/qcs/web/assets/474af58b [baseUrl] => /assets/474af58b [depends] => Array ( ) [js] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [kartik\base\WidgetAsset] => kartik\base\WidgetAsset Object ( [depends] => Array ( [0] => yii\web\JqueryAsset [1] => yii\bootstrap\BootstrapAsset ) [js] => Array ( [0] => js/kv-widgets.min.js ) [css] => Array ( [0] => css/kv-widgets.min.css ) [sourcePath] => /Users/arthur/www/qcs/vendor/kartik-v/yii2-krajee-base/assets [basePath] => /Users/arthur/www/qcs/web/assets/9bcfef1d [baseUrl] => /assets/9bcfef1d [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [yii\widgets\ActiveFormAsset] => yii\widgets\ActiveFormAsset Object ( [sourcePath] => /Users/arthur/www/qcs/vendor/yiisoft/yii2/assets [js] => Array ( [0] => yii.activeForm.js ) [depends] => Array ( [0] => yii\web\YiiAsset ) [basePath] => /Users/arthur/www/qcs/web/assets/4c23d013 [baseUrl] => /assets/4c23d013 [css] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) [yii\web\YiiAsset] => yii\web\YiiAsset Object ( [sourcePath] => /Users/arthur/www/qcs/vendor/yiisoft/yii2/assets [js] => Array ( [0] => yii.js ) [depends] => Array ( [0] => yii\web\JqueryAsset ) [basePath] => /Users/arthur/www/qcs/web/assets/4c23d013 [baseUrl] => /assets/4c23d013 [css] => Array ( ) [jsOptions] => Array ( ) [cssOptions] => Array ( ) [publishOptions] => Array ( ) ) ) [title] => Статистика чек-листа (табличный вид) [metaTags] => Array ( ) [linkTags] => Array ( ) [css] => Array ( ) [cssFiles] => Array ( ) [js] => Array ( [4] => Array (
The overall content is much bigger, so the above is an example of upper content.
As I said, in structure there are objects which breaks GridView functionality.
How have you constructed the $attributes
array?
The first bit you've shown doesn't look right to me.
[
[
'class' => 'yii\grid\SerialColumn'
],
'attribute' => 'errorContainedPercent',
'format' => 'raw '
]
I've found the answer now, sorry for disturbance - I'm closing this thread.
What steps will reproduce the problem?
by passing the object to GridView::widget method like this:
with $attributes not only the array, but an object. Check algorithm can detect an array, but can not an object and crushes.
What is the expected result?
The grid table should be full-filled and rendered on the page
What do you get instead?
An error
Additional info