Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove setting the block_prefix
  • Loading branch information
alexander-schranz committed Jul 19, 2022
commit e70a60cb040a235ed34faf25a6bf0c06f64909bd
12 changes: 10 additions & 2 deletions src/Collection/Form/CollectionTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public function buildView(FormView $view, FormInterface $form, array $options):
}
}

public function finishView(FormView $view, FormInterface $form, array $options): void
{
if (!$form->has('addButton')) {
return;
}

$addButton = $form->get('addButton');
$form->add('addButton', $options['add_type'], $options['add_options']);
}

public function configureOptions(OptionsResolver $resolver)
{
$attrNormalizer = function (Options $options, $value) {
Expand All @@ -80,7 +90,6 @@ public function configureOptions(OptionsResolver $resolver)
]);

$addOptionsNormalizer = function (Options $options, $value) {
$value['block_name'] = 'add_button';
$value['attr'] = \array_merge([
'data-action' => $options['attr']['data-controller'] . '#add',
], $value['attr'] ?? []);
Expand All @@ -89,7 +98,6 @@ public function configureOptions(OptionsResolver $resolver)
};

$deleteOptionsNormalizer = function (Options $options, $value) {
$value['block_name'] = 'delete_button';
$value['attr'] = \array_merge([
'data-action' => $options['attr']['data-controller'] . '#delete',
], $value['attr'] ?? []);
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Tests/app/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function form(Request $request, Environment $twig, FormFactoryInterface $
$team1->addPlayer($player1);
$player2 = new Player();
$player2->firstName = 'Player';
$player2->lastName = 'A1';
$player2->lastName = 'A2';
$team1->addPlayer($player2);
$team2 = new Team();
$team2->name = 'Symfony Core Team';
Expand Down