From c6db6f3d50167a9467a7609d49bb28a637a8e000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Sun, 19 Jun 2016 11:04:47 +0200 Subject: [PATCH] [Form] Add exception to FormRenderer about non-unique block names --- src/Symfony/Component/Form/FormRenderer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/FormRenderer.php b/src/Symfony/Component/Form/FormRenderer.php index b286ffdf41b2..15a8d08430cf 100644 --- a/src/Symfony/Component/Form/FormRenderer.php +++ b/src/Symfony/Component/Form/FormRenderer.php @@ -253,10 +253,11 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va // Escape if no resource exists for this block if (!$resource) { - throw new LogicException(sprintf( - 'Unable to render the form as none of the following blocks exist: "%s".', - implode('", "', array_reverse($blockNameHierarchy)) - )); + if (count($blockNameHierarchy) !== count(array_unique($blockNameHierarchy))) { + throw new LogicException(sprintf('Unable to render the form because the block names array contains duplicates: "%s".', implode('", "', array_reverse($blockNameHierarchy)))); + } + + throw new LogicException(sprintf('Unable to render the form as none of the following blocks exist: "%s".', implode('", "', array_reverse($blockNameHierarchy)))); } // Merge the passed with the existing attributes