title: Symfony2/ Use custom repository method in a formType
body: <p>I am new with Symfony2, hopefully I am clear enough.</p>
  
  <p>I have a repository:</p>
  
  <pre><code>class districtRepository extends EntityRepository
  {
       public function findAllFromCity($idCity)
      {
  
  
              return $this-&gt;createQueryBuilder('d')
                          -&gt;where('d.city = :city')
                          -&gt;setParameter('city', $idCity)
                          -&gt;orderBy('d.name', 'ASC');
                          -&gt;getQuery()
                          -&gt;getResult();
  
      }
  }
  </code></pre>
  
  <p>And a form type</p>
  
  <pre><code>class searchPropertyType extends AbstractType
  {
  
      public function getDefaultOptions(array $options)
      {
          // return array('validation_constraint' =&gt; $collectionConstraint
         return array ('required'=&gt;false, 'csrf_protection' =&gt; true); 
      }
  
  
      public function buildForm(FormBuilder $builder, array $options)
      {
  
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
          $builder
              -&gt;add('keywords')
              -&gt;add('disctrict')    
              -&gt;add('price_min')
              -&gt;add('price_max')
              -&gt;add('type')                                             
              -&gt;add('date_from' , 'date', array('widget' =&gt; 'single_text'))
              -&gt;add('date_to' , 'date', array('widget' =&gt; 'single_text'))
          ;
  
  
      }
  
      public function getName()
      {
          return 'searchProperty';
      }
  }
  </code></pre>
  
  <p>How do I simply use <code>findAllFromCity()</code> to get a list of option in <code>-&gt;add('disctrict')</code> ??</p>
  
  <p>I know the Query Builder solution, but it makes me repeating my code.</p>
  
  <p>I've read about the service container solution. Is is applicabe in my case? Can you show me how or put me on good tracks??</p>