title: Symfony 2 Form with select list
body: <p>How can i create a select list with values from a database table in Symfony 2?</p>
  
  <p>I have 2 entities: <strong>Student</strong> and <strong>Classroom</strong> with a ManyToOne relationship and i  need to create a form with the folowing fields: <strong>name</strong>, <strong>surname</strong>, <strong>age</strong>, <strong>classroom</strong>(select list from available classes).</p>
  
  <p>In my <strong>Student Form</strong> i have</p>
  
  <pre><code>    $builder
          -&gt;add('name')
          -&gt;add('surname')
          -&gt;add('age')
          -&gt;add('classroom', new ClassroomType())
      ;
  </code></pre>
  
  <p>In my <strong>Classroom Form</strong> i have this:</p>
  
  <pre><code>    $classrooms =$this-&gt;getDoctrine()-&gt;getRepository('UdoCatalogBundle:Classroom')-&gt;findAll();
      $builder
          -&gt;add('clasa','choice',array('choices' =&gt; array($classrooms-&gt;getId() =&gt; $classrooms-&gt;getName())));
  </code></pre>
  
  <p>I get this following error:</p>
  
  <pre><code>Fatal error: Call to undefined method Udo\CatalogBundle\Form\ClassroomType::getDoctrine() in /var/www/html/pos/src/Udo/CatalogBundle/Form/ClassroomType.php on line 13         
  </code></pre>
  
  <p>Kind Regards,
  Cearnau Dan</p>