I'm using omines datatables bundle in symfony 5 How could I define a checkbox as a label in the header of a datatable?
I'm using this but part of code not working
$dataTableFactory->create()
->add('selection', TextColumn::class, ['label' => '
<input type="checkbox" name="selectAll" id="selectAll">
'])
Thanks for your answer
I fixed this problem by using a custom template for the table (via datatables.yaml, with a copy of the original template in my project) and changing the filter applied on column.label:
<th> {{column.label | trans}} </th>
becomes
<th> {{column.label | raw}} </th>
It remains safe if the labels are not variables ... otherwise be careful.
We can keep both filters if raw is the last one (https://symfony.com/doc/current/translation/templates.html):
Using the translation tags or filters have the same effect, but with one subtle difference: automatic output escaping is only applied to translations using a filter. In other words, if you need to be sure that your translated message is not output escaped, you must apply the raw filter after the translation filter