Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 7, 2012 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2627464 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2627464 to your computer and use it in GitHub Desktop.
<?php
use MyCompany\BlogBundle\Entity\Article;
use MyCompany\BlogBundle\Form\ArticleType;
use Symfony\Component\HttpFoundation\Request;
/* ... rest of the controller */
public function updateAction(Request $request)
{
$article = new Article();
/* Create the form, add the article object */
$form = $this->createForm(new ArticleType(), $article);
if ($request->getMethod() == 'POST') {
/* This is where we handle the postback... */
$form->bindRequest($request);
if ($form->isValid()) {
/* Data is valid, do something in here*/
} else {
/* Data is invalid, do do something in here */
}
}
}
/* rest of the controller... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment