Skip to content

Instantly share code, notes, and snippets.

@ducho
Created June 20, 2023 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducho/a17c97f29bcaf4219a3c67c4a4bc8232 to your computer and use it in GitHub Desktop.
Save ducho/a17c97f29bcaf4219a3c67c4a4bc8232 to your computer and use it in GitHub Desktop.
#[Route('/{id}/edit', name: 'airport_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Airport $airport): Response
{
$form = $this->createForm(AirportType::class, $airport);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
return $this->redirectOrResponse($request);
}
$template = $request->isXmlHttpRequest() ? '_form.html.twig' : 'edit.html.twig';
return $this->renderForm('counter/airport/' . $template, [
'form' => $form,
], $this->getResponse($form));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment