Ok, figured out what I was doing wrong. Needed to pass in $slug into the updateAction parameter and use findOneBy(array) per nifr (thanks for the assist).
Updated route:
BloggerBlogBundle_blog_update:
path: /{id}/{slug}/update
defaults: { _controller: BloggerBlogBundle:Blog:update }
requirements:
id: \d+
Updated controller:
public function updateAction($id, $slug, Request $request)
{
$em = $this->getDoctrine()
->getManager();
$blog = $em->getRepository('BloggerBlogBundle:Blog')
->findOneBy(array(
'id' => $id,
'slug' => $slug
));
if (!$blog) {
throw $this->createNotFoundException(
'No blog was found for this id/slug: ' . $id. $slug
);
}
$form = $this->createFormBuilder($blog)
->add('title', 'text')
->add('author', 'text')
->add('blog', 'text')
->add('image', 'text')
->add('tags', 'text')
->add('save', 'submit')
->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$em->flush();
// return new Response('Blog was updated successfully');
return $this->redirect($this->generateUrl('BloggerBlogBundle_homepage'));
}
$build['form'] = $form->createView();
return $this->render('BloggerBlogBundle:Blog:create.html.twig', $build);
}