Я пытаюсь создать базовую форму, которая записывала бы нового игрока в спорт. Это взято из
примера Symfony по адресу:
https://symfony.com/doc/current/form/dy ... ed-dataКод
У меня есть 3 объекта:
PlayerList
https://github.com/ChimeraBlack1/Sympha ... erList.php
Спорт
https://github.com/ChimeraBlack1 /Symphart/blob/main/src/Entity/Sport.php
Позиция
https://github.com/ChimeraBlack1/Sympha ... sition.php
У меня есть форма:
NewPlayerType
https://github.com/ChimeraBlack1/Sympha ... erType.php
У меня есть контроллер:
NewPlayerController
https://github.com/ChimeraBlack1/Symphart/blob/main/src /Controller/NewPlayerController.php
Ошибка:
Код: Выделить всё
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?
Кажется, я получаю эту ошибку всякий раз, когда создаю форму с помощью конструктора форм типа «EntityType», например:
Ссылка:
https://github.com/ChimeraBlack1/Sympha ... erType.php (line 22)
Код: Выделить всё
->add('sport', EntityType::class, [
'class' => Sport::class,
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('s')
->orderBy('s.sport', 'ASC');
},
'choice_label' => 'sport',
])
Подробнее здесь: https://stackoverflow.com/questions/647 ... ust-be-man