Browse Source

Evolution #29 Forms: Contraintes

bastien 13 years ago
parent
commit
6b5e259afd

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

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

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

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

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

8
 use Gedmo\Mapping\Annotation as Gedmo;
8
 use Gedmo\Mapping\Annotation as Gedmo;
9
 use Doctrine\ORM\EntityManager;
9
 use Doctrine\ORM\EntityManager;
10
 use Muzich\CoreBundle\Entity\UsersTagsFavorites;
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
  * Cet entité est l'utilisateur ayant effectué la requête.
15
  * Cet entité est l'utilisateur ayant effectué la requête.

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

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