{% use "bootstrap_5_layout.html.twig" %}
{# this override allows attr.addon_after and attr.addon_before for input-group-addon control from the formType #}
{% block form_widget_simple -%}
{%- if type is not defined or type != 'hidden' %}
{%- set widget_class = ' form-control' %}
{%- if type|default('') == 'color' -%}
{%- set widget_class = widget_class ~ ' form-control-color' -%}
{%- elseif type|default('') == 'range' -%}
{%- set widget_class = ' form-range' -%}
{%- endif -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ widget_class)|trim}) -%}
{% endif -%}
{%- if type is defined and type in ['range', 'color'] %}
{# Attribute "required" is not supported #}
{% set required = false %}
{% endif -%}
{%- set type = type|default('text') -%}
{%- if type == 'range' or type == 'color' -%}
{# Attribute "required" is not supported #}
{%- set required = false -%}
{%- endif -%}
{% if attr.addon_after is defined or attr.addon_before is defined %}
<div class="input-group">
{% if attr.addon_before is defined %}<span class="input-group-text">{{ attr.addon_before | raw }}</span>{% endif %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% if attr.addon_after is defined %}<span class="input-group-text">{{ attr.addon_after | raw }}</span>{% endif %}
</div>
{% else %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endif %}
{%- endblock form_widget_simple %}