I have a strange problem on symfony 6.1
I searched, but I couldn't find the solution.
The error message: Neither the property "_token" nor one of the methods "_token()", "get_token()"/"is_token()"/"has_token()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
The error occurs when validation fails Error screen
#[Route('/new', name: 'app_commande_new', methods: ['GET', 'POST'])]
public function new(Request $request, ProductRepository $productRepository): Response
{
$commande = new Commande();
$form = $this->createForm(CommandeType::class, $commande);
//dd($request);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
dd($form->getData());
return $this->redirectToRoute('app_commande_index', [], Response::HTTP_SEE_OTHER);
}
//dd($form);
return $this->renderForm('commande/new.html.twig', [
'commande' => $commande,
'form' => $form,
]);
}
View
{{ form_start(form) }}
<div class="row">
<div class="col-md-6">
{{ form_row(form._token) }}
{{ form_row(form.client) }}
</div>
<div class="col-md-6">
{{ form_row(form.limitDate) }}
</div>
</div>
<button class="btn btn-primary" id="save" type="submit">{{ button_label|default('Save') }}</button>
{{ form_end(form, {render_rest: false}) }}
My post can't take more code here are the pictures of the forms code.