diff --git a/src/Resources/views/crud/index.html.twig b/src/Resources/views/crud/index.html.twig index e873ea36b2..f6266d1d1c 100644 --- a/src/Resources/views/crud/index.html.twig +++ b/src/Resources/views/crud/index.html.twig @@ -107,7 +107,7 @@ {% set ea_sort_asc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::ASC') %} {% set ea_sort_desc = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Option\\SortOrder::DESC') %} - {% for field in entities|first.fields ?? [] %} + {% for field in entities|filter(e => e.isAccessible)|first.fields ?? [] %} {% set is_sorting_field = ea.search.isSortingField(field.property) %} {% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %} {% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}