artisan-1.x-dev/components/form-element/form-element.twig
components/form-element/form-element.twig
{% set floating_label = floating_label ?: false %}
{% set attributes = attributes ?: create_attribute() %}
{% set description_attributes = description_attributes ?: create_attribute() %}
{%
set classes = [
'js-form-item',
'form-item',
'js-form-type-' ~ type|clean_class,
'form-item-' ~ name|clean_class,
'js-form-item-' ~ name|clean_class,
title_display not in ['after', 'before'] ? 'form-no-label',
disabled == 'disabled' ? 'form-disabled',
errors ? 'form-item--error',
]
%}
{%
set description_classes = [
'description',
description_display == 'invisible' ? 'visually-hidden',
]
%}
<div{{ attributes.addClass(classes) }}>
{% if floating_label %}
{{ children }}
{% endif %}
{% if label_display in ['before', 'invisible'] %}
{{ label }}
{% endif %}
{% if prefix is not empty %}
<span class="field-prefix">{{ prefix }}</span>
{% endif %}
{% if description_display == 'before' and description.content %}
<div{{ description.attributes }}>
{{ description.content }}
</div>
{% endif %}
{% if not floating_label %}
{{ children }}
{% endif %}
{% if suffix is not empty %}
<span class="field-suffix">{{ suffix }}</span>
{% endif %}
{% if label_display == 'after' %}
{{ label }}
{% endif %}
{% if errors %}
{% block errors %}
<div class="form-item--error-message">
{{ errors }}
</div>
{% endblock %}
{% endif %}
{% if description_display in ['after', 'invisible'] and description %}
<div{{ description_attributes.addClass(description_classes) }}>
{{ description }}
</div>
{% endif %}
</div>
