Last active
August 29, 2015 13:56
-
-
Save bchoquet-heliopsis/9113323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//src/Acme/FormBundle/Controller/FormController.php | |
namespace Acme\FormBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Acme\FormBundle\Entity\FormData; | |
use Symfony\Component\HttpFoundation\Request; | |
class FormController extends Controller | |
{ | |
public function formAction( Request $request ) | |
{ | |
$form = $this->getForm(); | |
if( 'POST' === $request->getMethod() ) | |
{ | |
$form->handleRequest( $request ); | |
if( $form->isValid() ) | |
{ | |
$this->handleData( $form->getData() ); | |
return new RedirectResponse( $this->generateUrl( 'custom_form_confirm' ) ); | |
} | |
} | |
return $this->render( | |
'AcmeFormBundle:Form:form.html.twig', | |
array( | |
'form' => $form->createView(), | |
) | |
); | |
} | |
private function getForm() | |
{ | |
return $this->createForm( 'acme_custom_form' ); | |
} | |
private function handleData( FormData $data ) | |
{ | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment