Closed Hanmac closed 4 years ago
Thank you for submitting this 👍🏻
Can you provide a PR?
I don't know what the right thing would be, does the twig message mean it needs an outer block?
Can you try this and change if the deprecation is gone?
list_choice.html.twig
{% block field %}
- {% spaceless %}
{% if field_description.options.choices is defined %}
{% if field_description.options.multiple is defined and field_description.options.multiple==true and value is iterable %}
{% set result = '' %}
{% set delimiter = field_description.options.delimiter|default(', ') %}
{% for val in value %}
{% if result is not empty %}
{% set result = result ~ delimiter %}
{% endif %}
{% if field_description.options.choices[val] is defined %}
{% if field_description.options.catalogue is not defined %}
{% set result = result ~ field_description.options.choices[val] %}
{% else %}
{% set result = result ~ field_description.options.choices[val]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% else %}
{% set result = result ~ val %}
{% endif %}
{% endfor %}
{% set value = result %}
{% elseif value in field_description.options.choices|keys %}
{% if field_description.options.catalogue is not defined %}
{% set value = field_description.options.choices[value] %}
{% else %}
{% set value = field_description.options.choices[value]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% endif %}
{% endif %}
{{ value }}
- {% endspaceless %}
{% endblock %}
@OskarStark i managed to do some testing, spaceless isn't the problem there.
this would fix the warning
diff --git a/src/Resources/views/CRUD/list_choice.html.twig b/src/Resources/views/CRUD/list_choice.html.twig
index 35e9cc15..39e811f7 100644
--- a/src/Resources/views/CRUD/list_choice.html.twig
+++ b/src/Resources/views/CRUD/list_choice.html.twig
@@ -18,14 +18,14 @@ file that was distributed with this source code.
%}
{% set x_editable_type = field_description.type|sonata_xeditable_type %}
-{% if is_editable and x_editable_type %}
- {% block field_span_attributes %}
+{% block field_span_attributes %}
+ {% if is_editable and x_editable_type %}
{% spaceless %}
{{ parent() }}
data-source="{{ field_description|sonata_xeditable_choices|json_encode }}"
{% endspaceless %}
- {% endblock %}
-{% endif %}
+ {% endif %}
+{% endblock %}
{% block field %}
{% spaceless %}
this is probably true for other CRUD templates
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Environment
Sonata packages
Symfony packages
Twig packages
PHP version
Subject
Twig since 2.5 shows Deprecated message that some features in the CRUD template will cause a Syntax Error in next Twig version.
Steps to reproduce
Twig Changelog:
Actual results