Skip to content

Instantly share code, notes, and snippets.

@frastel
Last active December 10, 2015 22:09
Show Gist options
  • Save frastel/4500311 to your computer and use it in GitHub Desktop.
Save frastel/4500311 to your computer and use it in GitHub Desktop.
<?php
namespace Acme\DemoBundle\Controller;
class FatController extends Controller
{
/**
* @Route("/{id}/edit", name="some_edit_route")
* @Method({"GET"})
* @Template()
*/
public function editAction($id)
{
$model = $this->loadModel($id);
$form = $this->createForm('some_type', $model);
return array('form' => $form);
}
/**
* @Route("/{id}/edit", name="some_update_route")
* @Method({"POST"})
* @Template("AcmeDemoBundle:FatController:edit.html.twig")
*/
public function updateAction(Request $request, $id)
{
$model = $this->loadModel($id);
$form = $this->createForm('some_type', $model);
$form->bind($request);
if ($form->isValid()) {
// updating stuff here ...
return $this->redirect($this->generateUrl('some_edit_route', array('id' => $id)));
}
return array('model' => $model);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment