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

{% set placeholder = field.placeholder|default(field.label)|striptags|trim %}

{% 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|striptags }}" alt="{{ field.hint|striptags }}" 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,
                placeholder: placeholder,
                required: field.required,
                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="{{ placeholder }}"
                {% if field.required %} required {% endif %}
            >
                {{- value -}}
            </textarea>
        {% endif %}
    </div>
{% endblock %}
