diff --git a/CHANGELOG_add_condition_macro_crud_action.md b/CHANGELOG_add_condition_macro_crud_action.md new file mode 100644 index 0000000..f1d918e --- /dev/null +++ b/CHANGELOG_add_condition_macro_crud_action.md @@ -0,0 +1,2 @@ +### Add +- Add `condition` parameter default true on `sonata_helper.html.twig` -> `crud_action` macro to add condition on action display diff --git a/templates/macros/sonata_helper.html.twig b/templates/macros/sonata_helper.html.twig index 2df9ed1..085e414 100644 --- a/templates/macros/sonata_helper.html.twig +++ b/templates/macros/sonata_helper.html.twig @@ -1,17 +1,19 @@ {% trans_default_domain 'admin' %} -{% macro crud_action(object, action, icon) %} - {% set url = admin.generateObjectUrl(action, object) %} - {% set label = ('action.' ~ action|u.snake)|trans %} - {% if admin.isCurrentRoute('list') %} - - - - {% else %} -
  • - - {{ label }} +{% macro crud_action(object, action, icon, condition = true) %} + {% if condition %} + {% set url = admin.generateObjectUrl(action, object) %} + {% set label = ('action.' ~ action|u.snake)|trans %} + {% if admin.isCurrentRoute('list') %} + + -
  • + {% else %} +
  • + + {{ label }} + +
  • + {% endif %} {% endif %} {% endmacro %}