{# Ported from myep's forms_admin.html.twig, trimmed to the blocks this app actually has. Registered globally in config/packages/twig.yaml rather than per-template: myep applies it with {% form_theme %} because it carries two themes, we only have one. Deliberately not ported: datepicker_widget, autocomplete_widget, multiselect_widget, money_widget, birthday_widget, abbreviated_date_widget -- all back myep-specific form types and Stimulus controllers that do not exist here. #} {% use 'form_div_layout.html.twig' %} {%- block form_row -%} {%- set widget_attr = {} -%} {%- if help is not empty -%} {%- set widget_attr = {attr: {'aria-describedby': id ~ "_help"}} -%} {%- endif -%} {{- form_label(form) -}} {{- form_widget(form, widget_attr) -}} {{- form_errors(form) -}} {{- form_help(form) -}} {%- endblock form_row -%} {%- block form_label -%} {% set class = 'block font-bold pb-2' %} {% if errors|length %} {% set class = class ~ ' text-red-500' %} {% endif %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' ' ~ class)|trim}) %} {{ parent() }} {%- endblock form_label -%} {%- block form_errors -%} {%- if errors|length > 0 -%} {%- endif -%} {%- endblock form_errors -%} {# The field class is repeated in each block on purpose: a top-level {% set %} in a form theme is not in scope inside its blocks, because each block is rendered with the caller's context. #} {%- block form_widget_simple -%} {%- set type = type|default('text') -%} {%- if type != 'hidden' -%} {%- set attr = attr|merge({'class': (attr.class|default('') ~ ' block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset text-sm')|trim }) -%} {%- if errors|length -%} {%- set attr = attr|merge({'class': attr.class ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%} {%- else -%} {%- set attr = attr|merge({'class': attr.class ~ ' placeholder:text-gray-400 focus:ring-primary' }) -%} {%- endif -%} {%- if disabled is defined and disabled -%} {%- set attr = attr|merge({'class': attr.class ~ ' cursor-not-allowed' }) -%} {%- endif -%} {%- endif -%} {{ parent() }} {%- endblock form_widget_simple -%} {%- block textarea_widget -%} {%- set attr = attr|merge({'class': (attr.class|default('') ~ ' block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset text-sm')|trim }) -%} {%- if errors|length -%} {%- set attr = attr|merge({'class': attr.class ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%} {%- else -%} {%- set attr = attr|merge({'class': attr.class ~ ' placeholder:text-gray-400 focus:ring-primary' }) -%} {%- endif -%} {{ parent() }} {%- endblock textarea_widget -%} {%- block choice_widget_collapsed -%} {%- set attr = attr|merge({'class': (attr.class|default('') ~ ' block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset text-sm')|trim }) -%} {%- if errors|length -%} {%- set attr = attr|merge({'class': attr.class ~ ' ring-red-500 focus:ring-red-500' }) -%} {%- else -%} {%- set attr = attr|merge({'class': attr.class ~ ' focus:ring-primary' }) -%} {%- endif -%} {{ parent() }} {%- endblock choice_widget_collapsed -%} {%- block checkbox_widget -%} {%- set attr = attr|merge({'class': (attr.class|default('') ~ ' h-4 w-4 rounded text-primary')|trim }) -%} {%- if errors|length -%} {%- set attr = attr|merge({'class': attr.class ~ ' border-red-500 text-red-500 focus:ring-red-500' }) -%} {%- else -%} {%- set attr = attr|merge({'class': attr.class ~ ' border-gray-300 focus:ring-primary' }) -%} {%- endif -%} {{ parent() }} {%- endblock checkbox_widget -%} {% block checkbox_row %}
{{ form_widget(form) }}
{{- form_errors(form) -}}
{% endblock %}