From a8f2c60368cdf6d25e04c5676d62d3a354f74d0b Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Sun, 14 Jun 2020 09:34:09 -0400 Subject: [PATCH] fixed block prefixes hierarchy of the CollectionType --- .../Component/Form/Extension/Core/Type/CollectionType.php | 2 +- .../Form/Tests/Extension/Core/Type/CollectionTypeTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index d4023ecb5f38..ea6a6d5ffec1 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -72,7 +72,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function finishView(FormView $view, FormInterface $form, array $options) { - $prefixOffset = -1; + $prefixOffset = -2; // check if the entry type also defines a block prefix /** @var FormInterface $entry */ foreach ($form as $entry) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index a610c24a044b..3d2ac4fe9c62 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -415,8 +415,8 @@ public function testEntriesBlockPrefixes() $expectedBlockPrefixes = [ 'form', - 'text', 'collection_entry', + 'text', '_fields_entry', ]; @@ -436,8 +436,8 @@ public function testEntriesBlockPrefixesWithCustomBlockPrefix() $this->assertCount(1, $collectionView); $this->assertSame([ 'form', - 'text', 'collection_entry', + 'text', 'field', '_fields_entry', ], $collectionView[0]->vars['block_prefixes']); @@ -454,8 +454,8 @@ public function testEntriesBlockPrefixesWithCustomBlockPrefixedType() $this->assertCount(1, $collectionView); $this->assertSame([ 'form', - 'block_prefixed_foo_text', 'collection_entry', + 'block_prefixed_foo_text', 'foo', '_fields_entry', ], $collectionView[0]->vars['block_prefixes']);