Browse Source

home: formulaire d'ajout: la saisie du groupe ne liste que les groupes possédés.

bastien 13 years ago
parent
commit
95017a6878

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

260
   {
260
   {
261
     return $this->groups_owned;
261
     return $this->groups_owned;
262
   }
262
   }
263
+
264
+  /**
265
+   * Get groups in array (id => name)
266
+   *
267
+   * @return Doctrine\Common\Collections\Collection 
268
+   */
269
+  public function getGroupsOwnedArray()
270
+  {
271
+    $groups = array();
272
+    foreach ($this->groups_owned as $group)
273
+    {
274
+      $groups[$group->getId()] = $group->getName();
275
+    }
276
+    return $groups;
277
+  }
263
   
278
   
264
   public function getSlug()
279
   public function getSlug()
265
   {
280
   {

+ 4 - 1
src/Muzich/HomeBundle/Controller/HomeController.php View File

21
   public function indexAction()
21
   public function indexAction()
22
   {
22
   {
23
     $search_object = $this->getElementSearcher();
23
     $search_object = $this->getElementSearcher();
24
+    $user = $this->getUser(true, array('join' => array(
25
+      'groups_owned'
26
+    )), true);
24
     
27
     
25
     $search_form = $this->createForm(
28
     $search_form = $this->createForm(
26
       new ElementSearchForm(), 
29
       new ElementSearchForm(), 
35
       array(),
38
       array(),
36
       array(
39
       array(
37
         'tags' => $tags,
40
         'tags' => $tags,
38
-        'groups' => $this->getGroupsArray(),
41
+        'groups' => $user->getGroupsOwnedArray(),
39
       )
42
       )
40
     );
43
     );
41
         
44