Проблемы при сабмите формы Symfony
контороллер
/**
* @Route("/customer/edit/{id}", name="customer_edit", methods={"GET"})
*/
public function edit($id, Request $request)
{
$customer = $this->customerRepository->findOneBy(['id' => $id]);
$form = $this->createForm(CustomerType::class, $customer);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
echo 1; die();
//return $this->redirectToRoute('form_edit_example', ['product'=>$product->getId()]);
}
return $this->render('customer/edit.html.twig', ['customer' => $customer, 'form' => $form->createView()]);
//$form = $this->createForm(CustomerType::class, $customer,);
//return $this->render('customer/edit.html.twig', ['customer' => $customer, 'form' => $form->createView()]);
}
CustomerType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstName', TextType::class, [
'constraints' => [new Length(['min' => 3])],
])
->add('lastName', TextType::class)
->add('email', TextType::class)
->add('phoneNumber', TextType::class)
->add('save', SubmitType::class);
}
routes
customer_edit:
path: /customer/edit/{id}
controller: App\Controller\CustomerController::edit
methods: [GET]
Выпадает следующая ошибка o route found for "POST /customer/edit/29": Method Not Allowed (Allow: GET).