247 lines
9.0 KiB
Twig

{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% block form_row %}
{% apply spaceless %}
{% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %}
<div class="mb-2">
<div class="row">
<div class="{% apply spaceless %}
{% if attr.class is defined and ('cf-title' in attr.class or 'cf-fields' in attr.class ) %}
col-sm-12
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
col-sm-2 col-md-4 clear
{% else %}
col-sm-4 clear
{% endif %}
{% endapply %}">
{% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %}
{{ form_label(form) }}
{% endif %}
</div>
<div class="{% apply spaceless %}
{% if attr.class is defined and 'cf-title' in attr.class %}
col-sm-12
{% elseif attr.class is defined and 'cf-fields' in attr.class %}
col-sm-12 parent
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
col-sm-2 col-md-8 multiple-cf-inline
{% else %}
col-sm-8
{% endif %}
{% endapply %}">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
</div>
{% else %}
{{ form_widget(form) }}
{% endif %}
{% endapply %}
{% endblock form_row %}
{% block choice_widget_expanded %}
{% apply spaceless %}
<div {{ block('widget_container_attributes') }} class="choice-widget-expanded">
{% for child in form %}
<span class="inline-choice">
{{ form_widget(child) }}
{{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }}
</span>
{% endfor %}
</div>
<script type="text/javascript">
document.addEventListener('load', function(e) {
chill.checkNullValuesInChoices("{{ form.vars.full_name }}");
});
</script>
{% endapply %}
{% endblock choice_widget_expanded %}
{% block choice_with_other_widget %}
{% apply spaceless %}
{% for child in form._choices %}
{%- if child.vars.value != '_other' -%}
<div class="inline-choice">
{{ form_widget(child) }}
{{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }}
</div>
{%- else -%}
<div class="container-fluid">
<div class="row g-0">
<div class="col-md-6">
<span class="inline-choice">
{{ form_widget(child) }}
{{ form_label(child, '', {'label_attr': { 'class' : 'inline'} }) }}
</span>
</div>
<div class="col-md-6">
{{ form_widget(form._other, {'attr': {'class': 'input-text-other-value'} }) }}
</div>
</div>
</div>
{%- endif -%}
{% endfor %}
<script type="text/javascript">
document.addEventListener('load', function(e) {
chill.checkNullValuesInChoices("{{ form._choices.vars.full_name }}");
});
</script>
{% endapply %}
{% endblock choice_with_other_widget %}
{% block money_widget %}
<div class="chill-form-money">
{{ block('form_widget_simple') }}
<span class="chill-form-money__money">{{ money_pattern|form_encode_currency }}</span>
</div>
{% endblock money_widget %}
{%- block time_widget -%}
{%- if widget == 'single_text' -%}
{{ block('form_widget_simple') }}
{%- else -%}
{%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%}
{% set attr = {'class' : 'time_compound ' ~ attr.class|default('') } %}
<div {{ block('widget_container_attributes') }}>
{{ form_widget(form.hour, vars) }}{% if with_minutes %}<span class="separator">:</span>{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}<span class="separator">:</span>{{ form_widget(form.second, vars) }}{% endif %}
</div>
{%- endif -%}
{%- endblock time_widget -%}
{% block form_errors %}
{% apply spaceless %}
{% if errors|length > 0 %}
<ul class="errors chill-form__errors">
{% for error in errors %}
<li class="chill-form_errors__entry {% if 'severity' in error.cause.constraint.payload|keys %}chill-form__errors__entry--{{ error.cause.constraint.payload.severity }}{% endif %}">{{ error.message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endapply %}
{% endblock form_errors %}
{% block _formatter__aggregator_placement_csv_formatter_row %}
<h3>{{ form_label(form) }}</h3>
{{ form_row(form.order) }}
{{ form_row(form.position) }}
{% endblock %}
{% block _formatter__aggregator_placement_spreadsheet_formatter_row %}
<h3>{{ form_label(form) }}</h3>
{{ form_row(form.order) }}
{% endblock %}
{% block chill_collection_widget %}
<div class="chill-collection">
<ul class="list-entry"
data-collection-name="{{ form.vars.name|escape('html_attr') }}"
data-collection-identifier="{{ form.vars.identifier|escape('html_attr') }}"
data-collection-button-remove-label="{{ form.vars.button_remove_label|trans|e }}"
data-collection-allow-add="{{ form.vars.allow_add|escape('html_attr') }}"
data-collection-allow-delete="{{ form.vars.allow_delete|escape('html_attr') }}">
{% for entry in form %}
<li class="entry" data-collection-is-persisted="1">
<div>
{{ form_widget(entry) }}
{{ form_errors(entry) }}
</div>
</li>
{% else %}
<li data-collection-empty-explain="1">
<span class="chill-no-data-statement">{{ form.vars.empty_collection_explain|default('No item')|trans }}</span>
</li>
{% endfor %}
</ul>
{% if form.vars.allow_add == 1 %}
<button class="add-entry btn btn-misc"
data-collection-add-target="{{ form.vars.name|escape('html_attr') }}"
data-form-prototype="{{ ('<div>' ~ form_widget(form.vars.prototype) ~ '</div>')|escape('html_attr') }}" >
<i class="fa fa-plus fa-fw"></i>
{{ form.vars.button_add_label|trans }}
</button>
{% endif %}
</div>
{% endblock %}
{% block address_widget %}
{% for entry in form %}
{% if entry.vars.name != 'customs' %}
{{ form_row(entry) }}
{% else %}
{{ form_widget(entry) }}
{% endif %}
{% endfor %}
{% endblock %}
{% block private_comment_row %}
{{ form_label(form) }}
{{ form_row(form) }}
{% endblock %}
{% block private_comment_widget %}
{% for entry in form %}
{{ form_widget(entry) }}
{% endfor %}
{% endblock %}
{% block comment_row %}
{{ form_label(form) }}
{{ form_row(form) }}
{% endblock %}
{% block comment_widget %}
{% for entry in form %}
{{ form_widget(entry) }}
{% endfor %}
{% endblock comment_widget %}
{% block pick_center_widget %}
{{ form_widget(form.center) }}
{% endblock pick_center_widget %}
{% block pick_center_row %}
{% if (not form.vars.is_hidden) %}
{{ block('form_row') }}
{% else %}
{{ form_widget(form.center) }}
{% endif %}
{% endblock %}
{% block pick_entity_dynamic_widget %}
{{ form_help(form)}}
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
<div data-module="pick-dynamic" data-types="{{ form.vars['types']|json_encode }}" data-multiple="{{ form.vars['multiple'] }}" data-uniqid="{{ form.vars['uniqid'] }}"></div>
{% endblock %}
{% block pick_postal_code_widget %}
{{ form_help(form)}}
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
<div data-module="pick-postal-code" data-uniqid="{{ form.vars['uniqid'] }}"></div>
{% endblock %}