{%- set labelId = (labelId is defined ? labelId : (id is defined ? id~'-label' : null)) %} {%- set fieldId = (fieldId is defined ? fieldId : (id is defined ? id~'-field' : null)) %} {%- set status = status ?? null %} {%- set label = label is defined and label != '__blank__' ? label : (block('label') ?? null) %} {%- set siteId = ((craft.app.getIsMultiSite() and siteId is defined) ? siteId : null) %} {%- set site = (siteId ? craft.app.sites.getSiteById(siteId) : null) %} {%- set required = required ?? false %} {%- set instructions = instructions ?? block('instructions') ?? null %} {%- set tip = tip ?? block('tip') ?? null %} {%- set warning = warning ?? block('warning') ?? null %} {%- set orientation = (site ? craft.app.i18n.getLocaleById(site.language) : craft.app.locale).getOrientation() %} {%- set translatable = translatable ?? (site is not same as(null)) %} {%- set errors = (errors is defined ? errors : null) -%} {%- set fieldClass = [ 'field', (first is defined and first ? 'first' : null), (errors ? 'has-errors' : null), (fieldClass is defined and fieldClass ? fieldClass : null) ]|filter|join(' ') %} {%- set fieldAttributes = { class: fieldClass, id: fieldId, }|merge(fieldAttributes ?? [], recursive=true) %} {%- if block('attr') is defined %} {%- set fieldAttributes = fieldAttributes|merge(('
')|parseAttr, recursive=true) %} {% endif %} {%- set inputAttributes = { class: ['input', orientation, errors ? 'errors']|filter, }|merge(inputAttributes ?? [], recursive=true) %}
{% if status %} {{ tag('div', { class: ['status-badge', status[0]], text: status[1][0:1]|upper, title: status[1], }) }} {% endif %} {% if label or instructions %}
{% if label %} {%- set labelAttributes = { id: labelId, class: required ? ['required'], for: id ?? null, }|merge(labelAttributes ?? [], recursive=true) %} {% endif %} {% if instructions %} {{ tag('div', { class: ['instructions'], html: instructions|md('gfm-comment')|replace('/&(\\w+);/', '&$1;'), }) }} {% endif %}
{% endif %}
{% block input %} {{ input|raw }} {% endblock %}
{% if tip %} {{ tag('p', { class: ['notice', 'with-icon'], html: tip|md(inlineOnly=true)|replace('/&(\\w+);/', '&$1;'), }) }} {% endif %} {% if warning %} {{ tag('p', { class: ['warning', 'with-icon'], html: warning|md(inlineOnly=true)|replace('/&(\\w+);/', '&$1;'), }) }} {% endif %} {% include "_includes/forms/errorList" with { errors: errors } %}