[Twig][Form] Twig theme for Foundation 6

This commit is contained in:
Rémi Leclerc 2019-12-08 14:11:57 +01:00 committed by Fabien Potencier
parent ae00ff4cfa
commit e47a134db0
2 changed files with 52 additions and 0 deletions

View File

@ -8,6 +8,8 @@ CHANGELOG
* removed `transChoice` filter and token
* `HttpFoundationExtension` requires a `UrlHelper` on instantiation
* removed support for implicit STDIN usage in the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
* added form theme for Foundation 6
* added support for Foundation 6 switches: add the `switch-input` class to the attributes of a `CheckboxType`
4.4.0
-----

View File

@ -0,0 +1,50 @@
{% extends "form_div_layout.html.twig" %}
{%- block checkbox_row -%}
{%- set parent_class = parent_class|default(attr.class|default('')) -%}
{%- if 'switch-input' in parent_class -%}
{{- form_label(form) -}}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' switch-input')|trim}) -%}
{{- form_widget(form) -}}
<label class="switch-paddle" for="{{ form.vars.id }}"></label>
{{- form_errors(form) -}}
{%- else -%}
{{- block('form_row') -}}
{%- endif -%}
{%- endblock checkbox_row -%}
{% block money_widget -%}
{% set prepend = not (money_pattern starts with '{{') %}
{% set append = not (money_pattern ends with '}}') %}
{% if prepend or append %}
<div class="input-group">
{% if prepend %}
<span class="input-group-label">{{ money_pattern|form_encode_currency }}</span>
{% endif %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' input-group-field')|trim}) %}
{{- block('form_widget_simple') -}}
{% if append %}
<span class="input-group-label">{{ money_pattern|form_encode_currency }}</span>
{% endif %}
</div>
{% else %}
{{- block('form_widget_simple') -}}
{% endif %}
{%- endblock money_widget %}
{% block percent_widget -%}
{%- if symbol -%}
<div class="input-group">
{% set attr = attr|merge({class: (attr.class|default('') ~ ' input-group-field')|trim}) %}
{{- block('form_widget_simple') -}}
<span class="input-group-label">{{ symbol|default('%') }}</span>
</div>
{%- else -%}
{{- block('form_widget_simple') -}}
{%- endif -%}
{%- endblock percent_widget %}
{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' button')|trim}) %}
{{- parent() -}}
{%- endblock button_widget %}