In a sonata admin project, using symfony 4, I would like to change the row opacity based on an entity field called visible, which is a boolean of course.
In other words, if the visible field is true, the opacity is going to be 1, else is going to be 0.2 or something like that.
I have done my research and I have found a couple of articles regarding the customization of the row templates, but none of those articles seems to be usefull to me. I know for a fact this is possible but I cant find the way to do it.
This is my list mapper.
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title', null, [
'label' => 'Titulo',
'sortable' => false
])
->add('description', null, [
'label' => 'Descripcion',
'sortable' => false
])
->add('idAuthor.name', null, [
'label' => 'Autor',
'sortable' => false
])
->add('idCategory.name', null, [
'label' => 'Categoria',
'sortable' => false
])
->add('position', null, [
'label' => 'Posicion',
'sortable' => false
])
->add('visible', 'boolean', [
'label' => 'Visible',
'editable' => true
])
->add('_action', null, [
'label' => 'Ordenar posicion',
'actions' => [
'move' => [
'template' => '@PixSortableBehavior/Default /_sort_drag_drop.html.twig',
'enable_top_bottom_buttons' => false
],
],
]);
}
As you can see there is my visible field, which can be edited on the page, i would like to change that row opacity depending on that variable
This is the html twig file where I think I have to code my logic, base_list_inner_row.html.twig file
{% for field_description in admin.list.elements %}
{% if field_description.name == '_action' and app.request.isXmlHttpRequest %}
{# Action buttons disabled in ajax view! #}
{% elseif field_description.getOption('ajax_hidden') == true and app.request.isXmlHttpRequest %}
{% else %}
{{ object|render_list_element(field_description) }}
{% endif %}
{% endfor %}