Ich versuche, eine Grundform zu erstellen, die einen neuen Spieler für eine Sportart anmeldet. Dies ist dem Symfony-
Beispiel entnommen unter:
https://symfony.com/doc/current/form/dy ... ed-dataDer Code
Ich habe 3 Entitäten:
PlayerList
https://github.com/ChimeraBlack1/Sympha ... erList.php
Sport
https://github.com/ChimeraBlack1 /Symhart/blob/main/src/Entity/Sport.php
Position
https://github.com/ChimeraBlack1/Sympha ... sition.php
Ich habe ein Formular:
NewPlayerType
https://github.com/ChimeraBlack1/Sympha ... erType.php
Ich habe ein Controller:
NewPlayerController
https://github.com/ChimeraBlack1/Sympha ... ler.phpDer Fehler:
Code: Select all
Entity of type "Doctrine\Common\Collections\ArrayCollection" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?
Ich erhalte diese Fehlermeldung anscheinend immer dann, wenn ich mit dem Formular-Builder ein Formular vom Typ „EntityType“ erstelle, etwa so:
Referenz:
https://github.com/ChimeraBlack1/Sympha ... erType.php (Zeile 22)
Code: Select all
->add('sport', EntityType::class, [
'class' => Sport::class,
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('s')
->orderBy('s.sport', 'ASC');
},
'choice_label' => 'sport',
])