Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. $id = $this->get('request')->get($this->admin->getIdParameter());
  2.  
  3. $object = $this->admin->getObject($id);
  4.  
  5. if (!$object) {
  6. throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
  7. }
  8.  
  9. if (false === $this->admin->isGranted('EDIT', $object)) {
  10. throw new AccessDeniedException();
  11. }
  12.  
  13. // On vérifie que l'annonce appartient bien à l'utilisateur connecté
  14. if($this->getUser()->getId() !== $object->getUser()->getId()) {
  15. throw new AccessDeniedException();
  16. }
  17.  
  18. $em = $this->getDoctrine()->getManager();
  19. $preparechoices = $em->getRepository('AcmeBundle:Entity')->findAll();
  20.  
  21. foreach($preparechoices as $c){
  22. $choices[$c->getId()] = $c->getLibelle();
  23. }
  24.  
  25.  
  26. $form = $this->createFormBuilder(array('choix'=>1))
  27. ->add('choix','choice',array('choices'=>$choices))
  28. ->add('submit','submit')
  29. ->getForm();
  30.  
  31. $view = $form->createView();
  32.  
  33.  
  34. $this->admin->setSubject($object);
  35. $this->get('twig')->getExtension('form')->renderer->setTheme($view, $this->admin->getFormTheme());
  36. return $this->render($this->admin->getTemplate('EDIT'), array(
  37. 'action' => 'edit',
  38. 'object' => $object,
  39. 'form' => $view,
  40. ));
  41. }
  42.  
  43. Impossible to access a key ("default") on a boolean variable ("")
  44.  
  45. {{ form_helper.render_groups(admin, form, admin.formtabs['default'].groups, has_tab) }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement