Skip to content

Commit

Permalink
feature #6720 Allow customize entity row attributes on index page (zo…
Browse files Browse the repository at this point in the history
…rn-v)

This PR was merged into the 4.x branch.

Discussion
----------

Allow customize entity row attributes on index page

In my project I need to highlight entity rows with different colors based on entity status.
Currently I need to copy all `table_body` just for add css class to row like `class="status-row status-row-{{ entity.instance.status.name|lower }}"`

With this patch I just need to add this in overrided template
```twig
{% block entity_row_attributes %}
    class="status-row status-row-{{ entity.instance.status.name|lower }}"
{% endblock %}
```

PS. After updating from 4.13, currently I need to update all my custom templates with this logic as `table_body`  was changed.

Commits
-------

ad6fd11 Allow customize entity row attributes on index page
  • Loading branch information
javiereguiluz committed Jan 18, 2025
2 parents 76a23ec + ad6fd11 commit 1128fb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion templates/crud/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
{% block table_body %}
{% for entity in entities %}
{% if entity.isAccessible %}
<tr data-id="{{ entity.primaryKeyValueAsString }}">
<tr data-id="{{ entity.primaryKeyValueAsString }}" {% block entity_row_attributes %}{% endblock %}>
{% if has_batch_actions %}
<td class="batch-actions-selector">
<div class="form-check">
Expand Down

0 comments on commit 1128fb4

Please sign in to comment.