title: How to get instance of entity repository in the Form (Type) class in Symfony 2?
body: <p>Let's say I have ordinary <code>*Type</code> class:</p>
  
  <pre><code>class LocationType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilder $builder, array $options)
      {
          $builder
              -&gt;add(...)
              ...
      }
  }
  </code></pre>
  
  <p>and one of the fields is a <code>choice</code> type. The values that need to be used as choice items are supposed to be retrieved from the database (from some particular entity repository).</p>
  
  <p>So the question is: how to get the repository in the <code>LocationType</code> class? Is passing it through the constructor the only way to get it?</p>
  
  <p><strong>UPD</strong>:</p>
  
  <p>I know about <code>entity</code> type but unfortunately I cannot use it, because my property is not and cannot be defined as <code>one-to-one</code> relation due to very complex relation conditions that Doctrine doesn't support (yet?). See <a href="https://stackoverflow.com/questions/9123264/how-to-specify-several-join-conditions-for-11-relationship-in-doctrine-2">How to specify several join conditions for 1:1 relationship in Doctrine 2</a> for additional details</p>