[Form] Deprecate searchAndRenderBlock
returning empty string
This commit is contained in:
parent
92c37b9711
commit
02f2f0ed39
@ -6,6 +6,25 @@ Cache
|
|||||||
|
|
||||||
* Deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead.
|
* Deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead.
|
||||||
|
|
||||||
|
Form
|
||||||
|
----
|
||||||
|
|
||||||
|
* Deprecated calling `FormRenderer::searchAndRenderBlock` for fields which were already rendered.
|
||||||
|
Instead of expecting such calls to return empty strings, check if the field has already been rendered.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```twig
|
||||||
|
{% for field in fieldsWithPotentialDuplicates %}
|
||||||
|
{{ form_widget(field) }}
|
||||||
|
{% endfor %}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
```twig
|
||||||
|
{% for field in fieldsWithPotentialDuplicates if not field.rendered %}
|
||||||
|
{{ form_widget(field) }}
|
||||||
|
{% endfor %}
|
||||||
|
```
|
||||||
Security
|
Security
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@
|
|||||||
{# Support #}
|
{# Support #}
|
||||||
|
|
||||||
{%- block form_rows -%}
|
{%- block form_rows -%}
|
||||||
{% for child in form %}
|
{% for child in form if not child.rendered %}
|
||||||
{{- form_row(child) -}}
|
{{- form_row(child) -}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{%- endblock form_rows -%}
|
{%- endblock form_rows -%}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
<?php foreach ($form as $child) : ?>
|
<?php foreach ($form as $child) : ?>
|
||||||
|
<?php if (!$child->isRendered()): ?>
|
||||||
<?php echo $view['form']->row($child) ?>
|
<?php echo $view['form']->row($child) ?>
|
||||||
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
4.2.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* deprecated calling `FormRenderer::searchAndRenderBlock` for fields which were already rendered
|
||||||
|
|
||||||
4.1.0
|
4.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -132,6 +132,9 @@ class FormRenderer implements FormRendererInterface
|
|||||||
$renderOnlyOnce = 'row' === $blockNameSuffix || 'widget' === $blockNameSuffix;
|
$renderOnlyOnce = 'row' === $blockNameSuffix || 'widget' === $blockNameSuffix;
|
||||||
|
|
||||||
if ($renderOnlyOnce && $view->isRendered()) {
|
if ($renderOnlyOnce && $view->isRendered()) {
|
||||||
|
// This is not allowed, because it would result in rendering same IDs multiple times, which is not valid.
|
||||||
|
@trigger_error(sprintf('You are calling "form_%s" for field "%s" which has already been rendered before, trying to render fields which were already rendered is deprecated since Symfony 4.2 and will throw an exception in 5.0.', $blockNameSuffix, $view->vars['name']), E_USER_DEPRECATED);
|
||||||
|
// throw new BadMethodCallException(sprintf('Field "%s" has already been rendered. Save result of previous render call to variable and output that instead.', $view->vars['name']));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user