Skip to content

Instantly share code, notes, and snippets.

@bchoquet-heliopsis
Last active August 29, 2015 13:56
Show Gist options
  • Save bchoquet-heliopsis/9113323 to your computer and use it in GitHub Desktop.
Save bchoquet-heliopsis/9113323 to your computer and use it in GitHub Desktop.
<?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