{% extends 'forms/' ~ layout|default('field') ~ '.html.twig' %}

{% set editor = gantry.platform.getEditor((scope ~ name)|fieldName, value|join("\n")) %}

{% block input %}
    {% if editor %}
        {{ editor|raw }}
    {% else %}
    <textarea
            {# required attribute structures #}
            name="{{ (scope ~ name)|fieldName|e }}"
            {# global attribute structures #}
            {{ block('global_attributes') }}
            {# non-gloval attribute structures #}
            {% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
            {% if field.cols is defined %}cols="{{ field.cols|e }}"{% endif %}
            {% if field.disabled in ['on', 'true', 1] %}disabled="disabled"{% endif %}
            {% if field.maxlength is defined %}maxlength="{{ field.maxlength|e }}"{% endif %}
            {% if field.minlength is defined %}minlength="{{ field.minlength|e }}"{% endif %}
            {% if field.placeholder is defined %}placeholder="{{ field.placeholder|e }}"{% endif %}
            {% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
            {% if field.required in ['on', 'true', 1] %}required="required"{% endif %}
            {% if field.rows is defined %}rows="{{ field.rows|e }}"{% endif %}
            {% if field.wrap in ['hard', 'soft'] %}wrap="{{ field.wrap|e }}"{% endif %}
            >{{ value|join("\n")|e }}</textarea>

    {% block reset_field %}{{ parent() }}{% endblock %}
    {% endif %}
{% endblock %}
