Skip to content

Instantly share code, notes, and snippets.

@wouterj
Created December 10, 2013 15:37
Show Gist options
  • Save wouterj/7892602 to your computer and use it in GitHub Desktop.
Save wouterj/7892602 to your computer and use it in GitHub Desktop.
<?php
// ...
class MyAwesomeController extends Controller
{
public function uselessAction(Request $request)
{
$user = new User();
$form = $this->createFormBuilder($user)
// ...
->getForm();
$form->bindRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$user->getId(); // gives the id
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment