namespace Rapsys\AirBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Form\FormError;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
//Prevent non-guest to access here
$this->denyAccessUnlessGranted('ROLE_GUEST', null, $this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Guest')]));
- //Reject non post requests
- if (!$request->isMethod('POST')) {
- throw new \RuntimeException('Request method MUST be POST');
- }
-
//Create ApplicationType form
$form = $this->createForm('Rapsys\AirBundle\Form\ApplicationType', null, [
//Set the action
$form->handleRequest($request);
//Handle invalid form
- if (!$form->isValid()) {
+ if (!$form->isSubmitted() || !$form->isValid()) {
//Set section
$section = $this->translator->trans('Application add');
//Set title
- $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
+ $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
//Render the view
return $this->render('@RapsysAir/application/add.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView()]+$this->context);
$section = $this->translator->trans('Application add');
//Set title
- $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
+ $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
//Render the view
return $this->render('@RapsysAir/application/add.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView()]+$this->context);
$section = $this->translator->trans('Application add');
//Set title
- $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
+ $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
//Render the view
return $this->render('@RapsysAir/application/add.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView()]+$this->context);