Skip to content

Commit

Permalink
feature #5313 translatable attribute values for actions (erelke)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

translatable attribute values for actions

I added translatable attribute values for actions. (ex. if attribute value is TranslatableMessage).

```
use function Symfony\Component\Translation\t;

...

Action::new('example')->setHtmlAttributes(['title' => t('help.example')]);
```

Commits
-------

7bbc18d translatable attribute values for actions
  • Loading branch information
javiereguiluz committed Jul 16, 2022
2 parents dd53683 + 7bbc18d commit 48f997a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Resources/views/crud/action.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{% if 'a' == action.htmlElement %}
<a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}"
href="{{ action.linkUrl }}"
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}>
{% for name, value in action.htmlAttributes %}{{ name }}="{{ (value.trans is defined ? value|trans : value)|e('html_attr') }}" {% endfor %}>
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%}
{%- if action.label is not empty -%}<span class="action-label">{{ action.label|trans|raw }}</span>{%- endif -%}
</a>
{% elseif 'button' == action.htmlElement %}
<button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}>
<button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ (value.trans is defined ? value|trans : value)|e('html_attr') }}" {% endfor %}>
<span class="btn-label">
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%}
{%- if action.label is not empty -%}<span class="action-label">{{ action.label|trans|raw }}</span>{%- endif -%}
Expand Down

0 comments on commit 48f997a

Please sign in to comment.