8000 fixed prototype block prefixes hierarchy of the CollectionType · symfony/symfony@65efc36 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65efc36

Browse files
committed
fixed prototype block prefixes hierarchy of the CollectionType
1 parent ccd9c1f commit 65efc36

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
9393
$view->vars['multipart'] = true;
9494
}
9595

96-
if ($prefixOffset > -2 && $prototype->getConfig()->getOption('block_prefix')) {
96+
if ($prefixOffset > -3 && $prototype->getConfig()->getOption('block_prefix')) {
9797
--$prefixOffset;
9898
}
9999

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,37 +428,66 @@ public function testEntriesBlockPrefixes()
428428
public function testEntriesBlockPrefixesWithCustomBlockPrefix()
429429
{
430430
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [''], [
431+
'allow_add' => true,
431432
'entry_options' => ['block_prefix' => 'field'],
432433
])
433434
->createView()
434435
;
435436

436-
$this->assertCount(1, $collectionView);
437-
$this->assertSame([
437+
$expectedBlockPrefixes = [
438438
'form',
439439
'collection_entry',
440440
'text',
441441
'field',
442442
'_fields_entry',
443-
], $collectionView[0]->vars['block_prefixes']);
443+
];
444+
445+
$this->assertCount(1, $collectionView);
446+
$this->assertSame($expectedBlockPrefixes, $collectionView[0]->vars['block_prefixes']);
447+
$this->assertSame($expectedBlockPrefixes, $collectionView->vars['prototype']->vars['block_prefixes']);
444448
}
445449

446450
public function testEntriesBlockPrefixesWithCustomBlockPrefixedType()
447451
{
448452
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [''], [
453+
'allow_add' => true,
449454
'entry_type' => BlockPrefixedFooTextType::class,
450455
])
451456
->createView()
452457
;
453458

454-
$this->assertCount(1, $collectionView);
455-
$this->assertSame([
459+
$expectedBlockPrefixes = [
456460
'form',
457461
'collection_entry',
458462
'block_prefixed_foo_text',
459463
'foo',
460464
'_fields_entry',
461-
], $collectionView[0]->vars['block_prefixes']);
465+
];
466+
467+
$this->assertCount(1, $collectionView);
468+
$this->assertSame($expectedBlockPrefixes, $collectionView[0]->vars['block_prefixes']);
469+
$this->assertSame($expectedBlockPrefixes, $collectionView->vars['prototype']->vars['block_prefixes']);
470+
}
471+
472+
public function testPrototypeBlockPrefixesWithCustomBlockPrefix()
473+
{
474+
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [], [
475+
'allow_add' => true,
476+
'entry_options' => ['block_prefix' => 'field'],
477+
])
478+
->createView()
479+
;
480+
481+
$expectedBlockPrefixes = [
482+
'form',
483+
'collection_entry',
484+
'text',
485+
'field',
486+
'_fields_entry',
487+
];
488+
489+
$this->assertCount(0, $collectionView);
490+
$this->assertSame($expectedBlockPrefixes, $collectionView->vars['prototype']->vars['block_prefixes']);
462491
}
463492

464493
public function testSubmitNull($expected = null, $norm = null, $view = null)

0 commit comments

Comments
 (0)
0