Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. namespace ACMEACMEBundleEntity;
  3.  
  4. use DoctrineORMMapping as ORM;
  5. use DoctrineORMMappingJoinTable;
  6. use SymfonyComponentValidatorConstraints as Assert;
  7.  
  8. class ActorSection
  9. {
  10. (...)
  11.  
  12. /**
  13. * @ORMManyToMany(targetEntity="ACMEACMEBundleEntityPost")
  14. * @ORMjoinTable(name="actor_section_post")
  15. * @AssertCount(
  16. * min = "1",
  17. * minMessage = "Merci de sélectionner au moins un poste",
  18. * )
  19. */
  20. private $posts;
  21.  
  22. (...)
  23. }
  24.  
  25. $handleRequest = $form->handleRequest($request);
  26. if ($request->isMethod('POST')){
  27. if( ! $handleRequest->isValid()){
  28. $request->getSession()->getFlashBag()->add('danger', "Error message");
  29. } else{
  30. $em->persist($Section);
  31. $em->flush();
  32. (...)
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement