ui2022/button--form.html.twig line 1

Open in your IDE?
  1. {% set icon = _args.icon|default(null) %}
  2. {% set text = _args.text|default(null) %}
  3. {% set type = _args.type|default('button') %}
  4. {% set styles = _args.styles|default(['default']) %}
  5. {% set unstyled = _args.unstyled|default(false) %}
  6. {% set form = _args.form|default({}) %}
  7. {% set attr = _args.attr|default({}) %}
  8. {% if styles is not iterable %}
  9.     {% set styles = styles|split(' ') %}
  10. {% endif %}
  11. {% if icon is not empty %}
  12.     {% set styles = styles|merge(['icon']) %}
  13. {% endif %}
  14. {% set attr = attr|merge(form|merge({
  15.     class: (unstyled) ? attr.class|default('') : '%s btn btn-%s'|format(
  16.         attr.class|default(''),
  17.         styles|join(' btn-')|trim
  18.     )|trim,
  19.     type: type,
  20. })) %}
  21. <button {{ attributes(attr) }}>
  22.     {%- if text -%}{{- text -}}{%- endif -%}
  23.     {%- if icon is not empty -%}<i class="{{- icon -}}"></i>{%- endif -%}
  24. </button>