Dear all, I have an issue when I export data with csvview. I want to export data from two associated table : ```php $this->response = $this->response->withDownload(‘Inventaire.csv’); $this->loadModel(‘Details’); $details = $this->Details->find(‘all’)->contain([‘Scans’]) ->where([‘Scans.idInventory’ => $idInventory]); $details->select([‘Scans.nb_elements’, ‘Details.ean’, ‘Details.qty’]); $this->set(compact(‘details’)); $this->viewBuilder() ->setClassName(‘CsvView.Csv’) ->setOptions([ ‘serialize’ => ‘details’, ‘delimiter’ => ‘;’, ‘enclosure’ => ‘’, ‘bom’ => true ]); ``` When I export data from only one table (Details) it works, but when I add “Scans” table I got this message: [ Notice (8)](javascript:void(0);): Array to string conversion [ ROOT\vendor\friendsofcake\cakephp-csvview\src\View\CsvView.php , line 333 ] It’s like he s trying to display an array instead of my field Scans.nb_elements. I check my variable $details and everything is ok. Could you help me about this ? Thanks in advance.
Activity
oresch commentedon Jul 21, 2021
Hi @nicocins ,
I was faced with the same issue and found the following solution.
Assuming you have Devices and DeviceStatuses tables.
The following did help me:
With
'status' => 'DeviceStatuses.name'I was finally able to use the depending information and export it to csv.And in the
$_extractarray I put the following - as already mentioned in the doc:Hope this helps
nicocins commentedon Jul 21, 2021
Thanks for your help ! i ll try !
tgoeminne commentedon Sep 7, 2022
It used to work in the older version, why is not working in this one? Need to update plugin so can work with associated models again.
dereuromark commentedon Jan 17, 2023
We should add a note into the docs here I guess.
dereuromark commentedon May 11, 2026
#147