130 lines
5.8 KiB
Twig
130 lines
5.8 KiB
Twig
{% 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 -%}
|
|
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
|
|
{{- form_label(form) -}}
|
|
{{- form_widget(form, widget_attr) -}}
|
|
{{- form_errors(form) -}}
|
|
{{- form_help(form) -}}
|
|
</div>
|
|
{%- endblock form_row -%}
|
|
|
|
{%- block form_label -%}
|
|
{% set class = ' font-bold' %}
|
|
{% 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 -%}
|
|
<ul>
|
|
{%- for error in errors -%}
|
|
<li class="text-red-500">{{ error.message }}</li>
|
|
{%- endfor -%}
|
|
</ul>
|
|
{%- endif -%}
|
|
{%- endblock form_errors -%}
|
|
|
|
{%- block form_widget_simple -%}
|
|
{%- set type = type|default('text') -%}
|
|
{%- if type != 'hidden' -%}
|
|
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' mt-2 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 sm:text-sm sm:leading-6')|trim }) -%}
|
|
{%- if errors|length -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%}
|
|
{% else %}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' placeholder:text-gray-400 focus:ring-primary' }) -%}
|
|
{%- endif -%}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{{ parent() }}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
|
{%- endif -%}
|
|
{%- endblock form_widget_simple -%}
|
|
|
|
{%- block textarea_widget -%}
|
|
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' mt-2 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 sm:text-sm sm:leading-6')|trim }) -%}
|
|
{%- if errors|length -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%}
|
|
{% else %}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' placeholder:text-gray-400 focus:ring-primary' }) -%}
|
|
{%- endif -%}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
|
{%- endif -%}
|
|
{{ parent() }}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
|
{%- endif -%}
|
|
{%- endblock textarea_widget -%}
|
|
|
|
{%- block choice_widget_collapsed -%}
|
|
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' mt-2 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 sm:text-sm sm:leading-6')|trim }) -%}
|
|
{%- if errors|length -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%}
|
|
{% else %}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' placeholder:text-gray-400 focus:ring-primary' }) -%}
|
|
{%- endif -%}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
|
{%- endif -%}
|
|
{{ parent() }}
|
|
{%- if disabled is defined and disabled == true -%}
|
|
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
|
{%- endif -%}
|
|
{%- endblock choice_widget_collapsed -%}
|
|
|
|
{%- block choice_widget_expanded -%}
|
|
<fieldset>
|
|
{% if form.vars.label %}
|
|
<legend class="text-base font-bold leading-6 text-gray-900">
|
|
{{ form.vars.label }}
|
|
</legend>
|
|
{% endif %}
|
|
<div class="mt-4 divide-y divide-gray-200 border-b border-t border-gray-200">
|
|
{%- for child in form %}
|
|
<div class="relative flex items-start py-4">
|
|
<div class="min-w-0 flex-1 text-sm leading-6">
|
|
<label for="{{ child.vars.id }}" class="select-none font-medium text-gray-900">
|
|
{{ child.vars.label }}
|
|
</label>
|
|
</div>
|
|
<div class="ml-3 flex h-6 items-center">
|
|
<input id="{{ child.vars.id }}" name="{{ child.vars.full_name }}" type="checkbox" class="h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary">
|
|
</div>
|
|
</div>
|
|
{% endfor -%}
|
|
</div>
|
|
</fieldset>
|
|
{%- endblock choice_widget_expanded -%}
|
|
|
|
{%- block birthday_widget -%}
|
|
<div class="grid grid-cols-3 gap-x-1">
|
|
{{ form_widget(form.children['day']) }}
|
|
{{ form_widget(form.children['month']) }}
|
|
{{ form_widget(form.children['year']) }}
|
|
</div>
|
|
{%- endblock -%}
|
|
|
|
{%- block money_widget -%}
|
|
{% set currency_class = 'absolute top-1/2 transform -translate-y-1/2 right-0 mr-2' %}
|
|
{% if errors|length %}
|
|
{% set currency_class = currency_class ~ ' text-red-500' %}
|
|
{% else %}
|
|
{% set currency_class = currency_class ~ ' text-gray-600' %}
|
|
{% endif %}
|
|
<div class="relative">
|
|
{{ block('form_widget_simple') }}
|
|
<span class="{{ currency_class }}">€</span>
|
|
</div>
|
|
{%- endblock money_widget -%}
|