Profiler error when using ActionsColumnType
First, thanks for the amazing work on this bundle!
I'm using version 0.30.2 of the bundle.
There are some issues when displaying the Data Tables section in the Profiler.
I'm using a ActionsColumnType and I get this error:
Neither the property "name" nor one of the methods "name()", "getname()"/"isname()"/"hasname()" or "__call()" exist and have public access in class "Symfony\Component\VarDumper\Cloner\Data" in @KreyuDataTable/data_collector/template.html.twig at line 134.
It seems, when using ActionsColumnType, that the action variable has no name.
action.type_class is not defined either.
Here is how I defined the actions:
->addColumn('actions', ActionsColumnType::class, [
'actions' => [
'edit' => [
'type' => ButtonActionType::class,
'type_options' => [
'href' => fn(Owner $owner) => $this->urlGenerator->generate('app_owner_edit', ['id' => $owner->getId()]),
'label' => 'Edit',
'variant' => 'primary'
],
],
'delete' => [
'type' => FormActionType::class,
'type_options' => [
'action' => fn(Owner $owner) => $this->urlGenerator->generate('app_owner_delete', ['id' => $owner->getId()]),
'confirmation' => true,
'label' => 'Delete',
'method' => 'POST',
'variant' => 'destructive',
],
],
],
'label' => 'Actions',
'priority' => 0,
'value_attr' => [
'class' => 'text-nowrap small',
],
])
Thanks for the report, and thank you for the kind words!
I dug deep into profiler with this issue. This issue exists only if row actions are defined through the ActionsColumnType, not by the $builder->addRowAction(). I am not yet sure how to fix this, but in the meantime, I suggest following workaround:
- add row actions using the data table builder's
addRowActionmethod, - create
ActionsColumnTypeproviding the row actions, instead of defining them in array.
For example:
$builder->addRowAction('edit', ButtonActionType::class, [
'href' => fn(Owner $owner) => $this->urlGenerator->generate('app_owner_edit', ['id' => $owner->getId()]),
'label' => 'Edit',
'variant' => 'primary'
]);
$builder->addColumn('actions', ActionsColumnType::class, [
'actions' => $builder->getRowActions(),
'label' => 'Actions',
'priority' => 0,
'value_attr' => [
'class' => 'text-nowrap small',
],
])
Then, the row actions will be properly defined in the data table, and rendered in the actions column.
I've same error and solved with the workaround. Maybe it can be interesting to add a warning message here https://data-table-bundle.swroblewski.pl/reference/types/column/actions.html @Kreyu