H
H
hdworker2015-05-05 00:40:58
Yii
hdworker, 2015-05-05 00:40:58

Yii2 GridView :: how to style multidimensional array in ArrayDataprovider?

Lord, hello.
The data is stored in the EAV model, the data is pulled out into a two-dimensional array:
result = [
post_title = [id, value],
weght = [id, value],
cost = [id, value]
]
How to present this array to the ActiveDataProvider so that the GridView accepts it and displayed three columns with names (post_title, weight, cost) ?
If you specify a "raw" array, it generates the error "array_merge(): Argument #2 is not an array".
Thank you in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hdworker, 2015-05-05
@hdworker

Gentlemen, the solution turned out when the multidimensional array was converted into a one-dimensional array (with four columns):

foreach ($argh as $key => $value) {
            foreach ($value as $inkey => $inval) {
                    $result[$i][$key] = $inval;
                    $i++;
            }
            $i = 0;
        }

Thanks to all!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question