This column is rendered with a custom template:
In this example, we want to display a formatted date and the time difference (with a twig filter named "ago").
- use setCellTemplate method (on Column object)
- define a custom template (wich extends or replace @KilikTable/_columnCell.html.twig)
Controller
$table->addColumn(
(new Column())
->setLabel('Création')
// setup custom template for cell (body) rendering
->setCellTemplate('application/_column_creation.html.twig')
->setSort(['a.creationDateTime' => 'asc'])
->setFilter(
(new Filter())
->setField('a.creationDateTime')
->setName('a_creationDateTime')
->setDataFormat(Filter::FORMAT_DATE)
)
);
View
{% extends "@KilikTable/_columnCell.html.twig" %}
{# @KilikTable/_columnCell.html.twig #}
{# @param table: Kilik\Table #}
{# @param column: Kilik\Column #}
{# @param row: array (from line result) #}
{% block tableBodyCellInner %}
{{ table.value(column,row) | date('d/m/Y H:i') }} - {{ table.value(column,row) | ago }}
{% endblock tableBodyCellInner %}