8000 bug #19127 [Form] Add exception to FormRenderer about non-unique bloc… · symfony/symfony@bbb75fa · GitHub
[go: up one dir, main page]

Skip to content

Commit bbb75fa

Browse files
committed
bug #19127 [Form] Add exception to FormRenderer about non-unique block names (enumag)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Add exception to FormRenderer about non-unique block names | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17874 | License | MIT | Doc PR | Commits ------- c6db6f3 [Form] Add exception to FormRenderer about non-unique block names
2 parents ec19a52 + c6db6f3 commit bbb75fa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Symfony/Component/Form/FormRenderer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,11 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va
253253

254254
// Escape if no resource exists for this block
255255
if (!$resource) {
256-
throw new LogicException(sprintf(
257-
'Unable to render the form as none of the following blocks exist: "%s".',
258-
implode('", "', array_reverse($blockNameHierarchy))
259-
));
256+
if (count($blockNameHierarchy) !== count(array_unique($blockNameHierarchy))) {
257+
throw new LogicException(sprintf('Unable to render the form because the block names array contains duplicates: "%s".', implode('", "', array_reverse($blockNameHierarchy))));
258+
}
259+
260+
throw new LogicException(sprintf('Unable to render the form as none of the following blocks exist: "%s".', implode('", "', array_reverse($blockNameHierarchy))));
260261
}
261262

262263
// Merge the passed with the existing attributes

0 commit comments

Comments
 (0)
0