Symfony render multiple objects
Solution 1:
So quick update here, i finally solved my problem. my misunderstanding was that it's possible to send multiple objects to the twig template. So that's my final code :
class descriptionFilm extends AbstractController{
/**
* @Route("/details/{id}", name="description")
* @Route("/", name="home")
*/
public function show( ManagerRegistry $doctrine, $id, Request $request): Response {
$film = $doctrine->getRepository(Film::class)->find($id);
$form = $this->createFormBuilder()
->add('submitForm', SubmitType::class, ['label'=>'delete film '])
->getForm()
;
if($form->isSubmitted() && $form->isValid()){
//Do some stuff here
return $this->redirectToRoute('home');
}
$form ->handleRequest($request);
return $this->render('details/description.html.twig', ['film' => $film, 'deleteFilm' => $form->createView()]);
}