passer une méthode PUT pour edition de formulaire
Bonjour, j'essaie vainement de changer la méthode pour l'envoie d'un fomulaire
À l'origine j'ai:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
/**
* @Route("/pin/{id<[0-9]+>}/edit", name="app_pin_edit", methods={"GET", "POST"})
*/
public function edit(Request $request, Pin $pin, EntityManagerInterface $em): Response
{
$form = $this->createForm(PinType::class, $pin);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$em->flush($pin);
return $this->redirectToRoute('app_home');
}
return $this->render('pins/edit.html.twig', [
"pin" => $pin,
"editForm" => $form->createView()
]);
} |
et tout fonctionne parfaitement , mais si je veux changer la methode : PUT
je fais
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
/**
* @Route("/pin/{id<[0-9]+>}/edit", name="app_pin_edit", methods={"GET", "PUT"})
*/
public function edit(Request $request, Pin $pin, EntityManagerInterface $em): Response
{
$form = $this->createForm(PinType::class, $pin, [
'method' => 'PUT',
]);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$em->flush($pin);
return $this->redirectToRoute('app_home');
}
return $this->render('pins/edit.html.twig', [
"pin" => $pin,
"editForm" => $form->createView()
]);
} |
j'ai une erreur:
Code:
1 2
|
No route found for "POST https://127.0.0.1:8001/pin/13/edit": Method Not Allowed (Allow: GET, PUT) |
J'aurai oublié ( voire pas compris : plus probable ) quelque chose ?
pourtant , j'ai bien
Code:
1 2
|
<input type="hidden" name="_method" value="PUT"> |
Dans le HTML de la page...