title: symfony 2, list of users
body: <p>I try to do a select with all my users. An admin has is his part a possibility to change the infos from the users. Email adress for example.</p>
  
  <p>I need to do a select with all the users, Then the admin choice a user and then he can change his infos.</p>
  
  <p>How can I do that?</p>
  
  <p>Thanks
  Best regards</p>
  
  <p>I tried to do so:</p>
  
  <pre><code>&lt;?php
   
  namespace gestEntrSym\gestBundle\Form;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\AbstractType;
   
  class entrainementGroupeForm extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
   
         $userManager = $this-&gt;get('fos_user.user_manager');
          $users = $userManager-&gt;findUsers();
          $builder
              -&gt;add('date');
      }
   
      public function getName()
      {
          return 'entrainementGroupe';
      }
  }
  </code></pre>
  
  <p>Then I have this error:</p>
  
  <p>Attempted to call method "get" on class "gestEntrSym\gestBundle\Form\entrainementGroupeForm" in C:\Users\ale252\Dropbox\wamp\www\gestEntrSym\src\gestEntrSym\gestBundle\Form\entrainementGroupeForm.php line 12. Did you mean to call: "getName", "getParent"?</p>
  
  <p>My idea is to take the users array to do a foreach and do a $builder->add('date') for all the values of the array.</p>
  
  <p>This is just a try with a date type, then I can do the same with a choice type.</p>
  
  <hr>
  
  <p>I have done anything like that:</p>
  
  <pre><code>&lt;?php
   
  namespace gestEntrSym\gestBundle\Form;
   
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\AbstractType;
  use Doctrine\ORM\EntityManager;
  use gestEntrSym\UserBundle\Entity\User;
   
  class entrainementGroupeForm extends AbstractType {
   
      /**
       * The entity manager
       *
       * @var EntityManager
       */
      private $users;
   
      /**
       * @param EntityManager
       */
      public function __construct($users) {
          $this-&gt;users = $users;
      }
   
      public function buildForm(FormBuilderInterface $builder, array $options) {
   
   
          foreach ($this-&gt;users as $value) {
  //            var_dump($value);
  //            exit;
              $builder-&gt;add('public', 'checkbox', array(
                  'label' =&gt; $value-&gt;getNom(),
                  'required' =&gt; false,
              ));
          }
      }
   
      public function getName() {
          return 'entrainementGroupe';
      }
   
  }
  </code></pre>
  
  <p>Then in my controller:</p>
  
  <pre><code>$userManager = $this-&gt;get('fos_user.user_manager');
          $users = $userManager-&gt;findUsers();
   
          $entrainementGroupe = new entrainementGroupe();
  //        var_dump($users[0]);
  //        exit;
          $form = $this-&gt;createForm(new entrainementGroupeForm($users), $entrainementGroupe);
  </code></pre>
  
  <p>But I have always an error:</p>
  
  <p>Neither the property "public" nor one of the methods "getPublic()", "public()", "isPublic()", "hasPublic()", "__get()" exist and have public access in class "gestEntrSym\gestBundle\Entity\entrainementGroupe".</p>
  
  <p>Somebody knows why?</p>
  
  <p>Thanks</p>