Adapt ScopePicker to replace Entity field by Hidden field if only one choice

This commit is contained in:
Jean-Francois Monfort
2021-01-19 11:33:20 +01:00
parent 3d0cb12a2d
commit 84e2cc9e02
3 changed files with 127 additions and 41 deletions

View File

@@ -18,17 +18,18 @@
{% block form_row %}
{% apply spaceless %}
{% if form.vars.hideLabel is not defined or form.vars.hideLabel == false %}
<div class="container">
<div class="{% apply spaceless %}
{% if attr.class is defined and ('cf-title' in attr.class or 'cf-fields' in attr.class ) %}
{% if attr.class is defined and ('cf-title' in attr.class or 'cf-fields' in attr.class ) %}
grid-12
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
grid-2 grid-mobile-4 grid-tablet-4 mobile-clear tablet-clear
{% else %}
grid-4 clear
{% endif %}
{% endapply %}">
{% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %}
{% 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>
@@ -47,6 +48,9 @@
{{ form_errors(form) }}
</div>
</div>
{% else %}
{{ form_widget(form) }}
{% endif %}
{% endapply %}
{% endblock form_row %}
@@ -182,4 +186,4 @@
<button class="chill-collection__button--add sc-button" data-collection-add-target="{{ form.vars.name|escape('html_attr') }}" data-form-prototype="{{ ('<div>' ~ form_widget(form.vars.prototype) ~ '</div>')|escape('html_attr') }}" >{{ form.vars.button_add_label|trans }}</button>
</div>
{% endif %}
{% endblock %}
{% endblock %}