{% assets %}
    {% block stylesheets %}
    {% endblock %}

    {% block javascript %}
    {% endblock %}
{% endassets -%}

{% assets in 'footer' %}
    {% block javascript_footer %}
    {% endblock %}
{% endassets -%}

{% set name = (name ?? field.name) -%}
{% set default_value = (default_value ?? field.default) -%}
{% set current_value = (current_value ?? value) -%}
{% set has_value = current_value is not null -%}
{% set value = has_value ? current_value : default_value -%}

{% block field %}
{% if not field.isset or value is not null %}
    <div class="settings-param {{ field.type|replace({'.': '-'}) }}">
        {% block overridable %}
        {% set field_overridable = field.overridable ?? (field.overrideable ?? true) %}
        {% if overrideable and (field_overridable or has_value) %}
            {% include 'forms/override.html.twig' with {'scope': scope, 'name': name, 'field': field} %}
        {% endif %}
        {% endblock %}
        {% block contents %}
            <span class="settings-param-title float-left">
                {% block label %}
                    {% if field.description %}
                        {% set description = field.description|trans_key('GANTRY5_FORM_FIELD', scope, name, 'DESC') %}
                        <span data-tip="{{ description|raw }}" data-tip-place="top-right" aria-label="{{ description }}" data-title="{{ description }}">
                            {{ field.label|trans_key('GANTRY5_FORM_FIELD', scope, name, 'LABEL') }}
                        </span>
                    {% else %}
                        {{ field.label|trans_key('GANTRY5_FORM_FIELD', scope, name, 'LABEL') }}
                    {% endif %}
                    {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
                {% endblock %}
            </span>
            <div class="settings-param-field">
                {% block group %}
                    {% block input %}
                        <input
                                {# required attribute structures #}
                                name="{{ (scope ~ name)|fieldName }}"
                                value="{{ value|join(', ') }}"
                                {# global attribute structures #}
                                {% block global_attributes %}
                                    {% if field.class is defined %} class="{{ field.class }}" {% endif %}
                                    {% if field.id is defined %} id="{{ field.id }}" {% endif %}
                                    {% if field.style is defined %} style="{{ field.style }}" {% endif %}
                                    {% if field.title is defined %} title="{{ field.title }}" {% endif %}
                                    {% if field.override_target is defined %} data-override-target="{{ field.override_target|e('html_attr') }}" {% endif %}
                                    aria-label="{{ (scope ~ name)|replace({'.': ' '})|title|trim }}"
                                {% endblock %}
                                />

                        {% block reset_field -%}
                            {% if field.reset_field is not defined or field.reset_field in ['on', 'true', 1] %}
                                <span class="g-reset-field" data-g-reset-field="{{ (scope ~ name)|fieldName }}"><i class="fa  fa-fw fa-times-circle" aria-hidden="true"></i></span>
                            {% endif %}
                        {%- endblock %}
                    {% endblock %}
                {% endblock %}
            </div>
        {% endblock %}
    </div>
{% endif %}
{% endblock %}
