Symfony succesfully resolves your Company
entity using the id
parameter in your route. However, Symfony can't automatically resolve more than one entity unless your route contains more parameters. Therefore, $playlistForCompany
can't be resolved as Symfony does not know which entity to query.
As you are not persisting any new value in your code, I assume that $playlistForCompany
must be an existing entity, somewhat related to $company
.
- If your
Company
entity has an association field to the PlaylistForCompany
entity, you can retrieve it using the corresponding getter
.
- If not, you will have to use your
PlaylistRepository
and manually retrieve it.
public function parcours(Company $company, Request $request): Response
{
$entityManager = $this->getDoctrine()->getManager();
$playlistRepository = $entityManager->getRepository(PlaylistForCompany::class);
$playlistForCompany = $company->getPlaylistForCompany(); // 1. with getter
$playlistForCompany = $playlistRepository->find(...); // 2. with repository
$form = $this->createForm(PlaylistForCompanyType::class, $playlistForCompany);
$form->handleRequest($request);
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…