Guest User

Untitled

a guest
Jan 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public function edit_articleAction(Request $request, $id)
  2. {
  3. $em = $this->getDoctrine()->getEntityManager();
  4. $article = $em->getRepository('PageNewsBundle:Article')
  5. ->find($id);
  6.  
  7. if (!$article) {
  8. return $this->redirect($this->generateUrl('page_core_admin'));
  9. }
  10.  
  11. $form = $this->createFormBuilder($article)
  12. ->add('title', 'text')
  13. ->add('subtitle', 'textarea')
  14. ->add('body','textarea', array('required' => false, 'attr' => array('class' => 'ckeditor')))
  15. ->add('articlecategory', 'entity', array(
  16. 'class' => 'PageNewsBundle:ArticleCategory',
  17. //'preferred_choices' => array($article->getArticlecategory()->getId()),
  18. ))
  19. ->getForm();
  20.  
  21. if ($request->getMethod() == 'POST') {
  22. $form->bindRequest($request);
  23. if ($form->isValid()) {
  24.  
  25. $em->flush();
  26.  
  27. return $this->redirect($this->generateUrl('page_core_admin'));
  28. }
  29. }
  30.  
  31. return $this->render('PageNewsBundle:Article:edit_article.html.twig', array(
  32. 'form' => $form->createView(),
  33. 'result' => $article,
  34. ));
  35. }
  36.  
  37. Warning: spl_object_hash() expects parameter 1 to be object, string given in ...
Add Comment
Please, Sign In to add comment