Skip to content

Commit

Permalink
bug #19127 [Form] Add exception to FormRenderer about non-unique bloc…
Browse files Browse the repository at this point in the history
…k 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
  • Loading branch information
fabpot committed Jun 21, 2016
2 parents ec19a52 + c6db6f3 commit bbb75fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Symfony/Component/Form/FormRenderer.php
Expand Up @@ -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
Expand Down

0 comments on commit bbb75fa

Please sign in to comment.