{% extends "@bazar/layouts/input.twig" %}

{% block groupClass %}
    {{ field.syntax }}
{% endblock %}

{% block label %}
    {% if field.required %}<span class="symbole_obligatoire"></span>{% endif %}
    {% if field.hint %}
        <img loading="lazy" class="tooltip_aide" title="{{ field.hint|raw('html') }}" alt="{{ field.hint|raw('html') }}" src="tools/bazar/presentation/images/aide.png" width="16" height="16" />
    {% endif %}
    {{ field.label|raw }}
    {% if field.maxChars and (field.syntax == 'nohtml' or field.syntax == 'wiki-textarea') %}(<span class="charsRemaining">{{ field.maxChars }}</span> caractères restants){% endif %}
{% endblock %}

{% block input %}
    {{ include_css('tools/bazar/presentation/styles/inputs/textarea.css') }}

    <div id="{{ field.name ~ 'Container' }}">
        {% if field.syntax == 'wiki-textarea' %}
            {{ renderAction(
              'aceditor',
              { 
                name: field.name,
                value: value,
                rows: field.numRows,
                maxChars: field.maxChars,
                tempTag: tempTag
              }
            )|raw }}
        {% else %}
            <textarea
                id="{{ field.name }}"
                name="{{ field.name }}"
                class="form-control {% if field.syntax == 'html' %}summernote{% else %}{{ field.syntax }}{% endif %}"
                rows="{{ field.numRows }}"
                {% if field.size %}cols="{{ field.size }}"{% endif %}
                {% if field.maxChars %}maxlength="{{ field.maxChars }}"{% endif %}
                placeholder="{{ field.label|raw('html')|striptags }}"
                {% if field.required %}required{% endif %}
            >
                {{- value -}}
            </textarea>
        {% endif %}
    </div>
{% endblock %}
