Browse Source

Evolution #29 Forms: Contraintes

bastien 12 years ago
parent
commit
6b5e259afd

+ 6 - 0
src/Muzich/CoreBundle/Entity/Element.php View File

@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
6 6
 use \Doctrine\Common\Collections\ArrayCollection;
7 7
 use Gedmo\Mapping\Annotation as Gedmo;
8 8
 use Doctrine\ORM\EntityManager;
9
+use Symfony\Component\Validator\Constraints as Assert;
9 10
 use Muzich\CoreBundle\Validator as MuzichAssert;
10 11
 
11 12
 /**
@@ -74,6 +75,8 @@ class Element
74 75
    * L'url est l'url du media. 
75 76
    * 
76 77
    * @ORM\Column(type="string", length=1024)
78
+   * @Assert\NotBlank()
79
+   * @Assert\MaxLength(1024)
77 80
    * @var type string
78 81
    */
79 82
   protected $url;
@@ -82,6 +85,9 @@ class Element
82 85
    * Libellé du media
83 86
    * 
84 87
    * @ORM\Column(type="string", length=128)
88
+   * @Assert\NotBlank()
89
+   * @Assert\MinLength(limit=3)
90
+   * @Assert\MaxLength(64)
85 91
    * @var type string
86 92
    */
87 93
   protected $name;

+ 6 - 0
src/Muzich/CoreBundle/Entity/Group.php View File

@@ -7,6 +7,8 @@ use \Doctrine\Common\Collections\ArrayCollection;
7 7
 use Gedmo\Mapping\Annotation as Gedmo;
8 8
 use Doctrine\ORM\EntityManager;
9 9
 use Muzich\CoreBundle\Entity\GroupsTagsFavorites;
10
+use Symfony\Component\Validator\Constraints as Assert;
11
+use Muzich\CoreBundle\Validator as MuzichAssert;
10 12
 
11 13
 /**
12 14
  * Le groupe est une sorte de liste de diffusion, a laquelle les
@@ -33,6 +35,9 @@ class Group
33 35
    * Nom du groupe
34 36
    * 
35 37
    * @ORM\Column(type="string", length=128)
38
+   * @Assert\NotBlank()
39
+   * @Assert\MinLength(limit=3)
40
+   * @Assert\MaxLength(64)
36 41
    * @var type string
37 42
    */
38 43
   protected $name;
@@ -47,6 +52,7 @@ class Group
47 52
    * Description
48 53
    * 
49 54
    * @ORM\Column(type="text")
55
+   * @Assert\MaxLength(2048)
50 56
    * @var type string
51 57
    */
52 58
   protected $description;

+ 2 - 0
src/Muzich/CoreBundle/Entity/User.php View File

@@ -8,6 +8,8 @@ use \Doctrine\Common\Collections\ArrayCollection;
8 8
 use Gedmo\Mapping\Annotation as Gedmo;
9 9
 use Doctrine\ORM\EntityManager;
10 10
 use Muzich\CoreBundle\Entity\UsersTagsFavorites;
11
+use Symfony\Component\Validator\Constraints as Assert;
12
+use Muzich\CoreBundle\Validator as MuzichAssert;
11 13
 
12 14
 /**
13 15
  * Cet entité est l'utilisateur ayant effectué la requête.

+ 1 - 1
src/Muzich/GroupBundle/Controller/DefaultController.php View File

@@ -78,7 +78,7 @@ class DefaultController extends Controller
78 78
       $this->setFlash('error', 'group.create.failure');
79 79
       
80 80
       return $this->render(
81
-        'GroupBundle:Default:myList.html.twig', 
81
+        'MuzichGroupBundle:Default:myList.html.twig', 
82 82
          array(
83 83
            'groups'   => $user->getGroupsOwned(),
84 84
            'form_new' => $form_new->createView()