Skip to content

Instantly share code, notes, and snippets.

@webmozart
Created February 24, 2011 23:12
Show Gist options
  • Select an option

  • Save webmozart/843094 to your computer and use it in GitHub Desktop.

Select an option

Save webmozart/843094 to your computer and use it in GitHub Desktop.
protected function editAction(Post $post)
{
$factory = new HelloFormFactory($this->get('form.factory'));
$form = $factory->getPostForm($post);
if ($this->get('request')->getMethod() === 'POST') {
$form->bindRequest($this->get('request'));
if ($form->isValid()) {
$em = $this->get('doctrine.orm.default_entity_manager');
$em->persist($post);
$em->flush();
return new RedirectResponse($this->generateUrl('hello_index'));
}
}
return $this->render('HelloBundle:Hello:edit.html.twig', array(
'form' => $form->getRenderer(),
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment