datatables-bundle
datatables-bundle copied to clipboard
Passing additional data to the TwigColumn template render
Currently you can only render a Twig template and it passes the current row and the normal value to the template. It would be cool to have the ability to add more values to the view.
$table->add('field', TwigColumn::class, [
'template' => 'tenant/students/snippets/overview/courses.html.twig',
'variables' => [ // <-- Add-in extra variables to the view
'var' => 'value',
],
]);
From my understanding, this is already possible:
$table->add('field', TwigColumn::class)->setTemplate('tenant/students/snippets/overview/courses.html.twig', ['var' => 'value']);
However, I do agree that it is strange that the TwigColumn
does not support this by default, so I added a PR for the feature. #254
@Ahummeling that is NOT the same. that code runs setTemplate
on the DataTable instance, not the column. It overrides the rendering of the entire table.
@Ahummeling that is NOT the same. that code runs
setTemplate
on the DataTable instance, not the column. It overrides the rendering of the entire table.
Oh, I see. My bad, sorry! Thanks for clarifying
Stale issue message