WIP: Implement form theme

This commit is contained in:
Björn Fromme
2023-09-15 12:15:44 +02:00
parent 1127f08abc
commit 975d031591
2 changed files with 19 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
twig:
default_path: '%kernel.project_dir%/templates'
form_themes: ['forms.html.twig']
when@test:
twig:
+18
View File
@@ -0,0 +1,18 @@
{% use 'form_div_layout.html.twig' %}
{%- block form_widget_simple -%}
{%- set type = type|default('text') -%}
{%- if type != 'hidden' -%}
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' mt-2 appearance-none text-slate-900 bg-white rounded-md block w-full px-3 h-10 shadow-sm sm:text-sm focus:outline-none placeholder:text-slate-400 focus:ring-2 focus:ring-primary ring-1 ring-slate-200')|trim }) -%}
{%- if errors|length -%}
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' ring-red-500 placeholder-red-500 focus:ring-red-500' }) -%}
{%- 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 -%}