atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
440 stars 105 forks source link

addDecorator with tooltip not working on grids with addTotals line #1799

Open mkrecek234 opened 2 years ago

mkrecek234 commented 2 years ago

Steps to reproduce:

  1. Setup any grid or crud to have a decorator and also the table to have addTotals line:

    public function setModel(Model $model, $fields = null): void
    {    
    
        parent::setModel($model);
    
        $this->addDecorator('account', new  \Atk4\Ui\Table\Column\Tooltip(
            [
                'tooltip_field' => 'account_description',
                'icon' => 'info circle blue',
            ]));
        $grid->table->addTotals(['booked_date' => 'Balance', 'value' => ['sum']]);
     ...}
  2. If you keep the addTotals line it will throw an error:

    Critical Error
    Error: Call to a member function getTag() on array

    If you delete the addTotals line, it will work.

mvorisek commented 2 years ago

I can reproduce with this code:

// https://github.com/atk4/ui/issues/1799
$table->addDecorator('salary', new \Atk4\Ui\Table\Column\Tooltip([
    'tooltip_field' => 'name',
    'icon' => 'info circle blue',
]));

on demos/collection/table.php

but I get slightly different exception:

Error: Call to a member function getTotalsCellHtml() on array

Stack Trace
  | vendor/atk4/ui/src/Table.php:672 |   |  
11 | vendor/atk4/ui/src/Table.php:484 |   | getTotalsRowHtml()
10 | vendor/atk4/ui/src/View.php:657 |   | renderView()
9 | vendor/atk4/ui/src/View.php:729 |   | renderAll()
8 | vendor/atk4/ui/src/View.php:634 |   | getHtml()
7 | vendor/atk4/ui/src/View.php:659 |   | recursiveRender()
6 | vendor/atk4/ui/src/View.php:729 |   | renderAll()
5 | vendor/atk4/ui/src/View.php:634 |   | getHtml()
4 | vendor/atk4/ui/src/View.php:659 |   | recursiveRender()
3 | vendor/atk4/ui/src/App.php:554 |   | renderAll()
2 | vendor/atk4/ui/src/App.php:1018 |   | run()
1 |   |   | Atk4\Ui\{closure}()

but the line is covered https://app.codecov.io/gh/atk4/ui/blob/develop/src/Table.php, so some unexpected data structure is passed