title: Get value from database and insert it in a dropdown Symfony 3
body: <p>Hello I try to insert data from the database into a dropdown or ChoiceType. The Data comes from two different databases.</p>
  
  <p>Here is my <code>IndexController</code>:</p>
  
  <pre><code>public function indexAction(Request $request){
   $em = $this-&gt;getDoctrine()-&gt;getManager();
      //$city = new Cities();-&gt;select("c.id,c.active,c.code,t.text name")
   $query = $em-&gt;createQueryBuilder()
        -&gt;select("c")
        -&gt;from("DataBaseBundle:Countries","c")
        -&gt;innerJoin("DataBaseBundle:Translationtext","t","WITH","c.translation=t.translation");
   $country = $query-&gt;getQuery()-&gt;getResult();
   if (!$country){
        throw $this-&gt;createNotFoundException("Country not found");
   }
   $form = $this-&gt;createForm(CountriesType::class,$country);
  
   if ($form-&gt;isValid()) {
      $user = $form-&gt;getData();
      $em-&gt;persist($user);
      $em-&gt;flush();
  }
   return $this-&gt;render('ParametersBundle:Countries:index.html.twig', array(
              'form' =&gt; $form-&gt;createView(),));
       }
  }
  </code></pre>
  
  <p>And my Form called <code>CountriesType</code>:</p>
  
  <pre><code>&lt;?php
  
  namespace ParametersBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  
  class CountriesType extends AbstractType
  {
      private $fooChoices = [
          0 =&gt; 'choice naught',
          1 =&gt; 'choice one',
          2 =&gt; 'choice deuce',
      ];
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options){
          $builder-&gt;add('active',CheckboxType::class)
          -&gt;add('countries',TextType::class)
          -&gt;add('countries',ChoiceType::class,['choices' =&gt; $this-&gt;fooChoices,])
          -&gt;add('save', SubmitType::class, array('label' =&gt; 'Create Post'));
      }
      /**
       * {@inheritdoc}
       */
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'choices' =&gt; array(
                  'm' =&gt; 'Male',
                  'f' =&gt; 'Female',
              )
              //'data_class' =&gt; 'DataBaseBundle\Entity\Cities'
          ));
      }
  
      /**
       * {@inheritdoc}
       */
      public function getBlockPrefix()
      {
          return 'country';
      }
  
  
  }
  </code></pre>
  
  <p>The FooChoices brings data from the code and not from the database.</p>
  
  <p><strong>EDIT:</strong> And my Entity (The traslation is in another database called Traslations)</p>
  
  <pre><code>    &lt;?php
  
  namespace DataBaseBundle\Entity;
  
  /**
   * Countries
   */
  class Countries
  {
      /**
       * @var integer
       */
  private $id;
  
  /**
   * @var integer
   */
  private $active = '1';
  
  /**
   * @var string
   */
  private $code2;
  
  /**
   * @var string
   */
  private $code3;
  
  /**
   * @var \DataBaseBundle\Entity\Continents
   */
  private $continents;
  
  /**
   * @var \DataBaseBundle\Entity\Translation
   */
  private $translation;
  
  
  /**
   * Get id
   *
   * @return integer
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Set active
   *
   * @param integer $active
   *
   * @return Countries
   */
  public function setActive($active)
  {
      $this-&gt;active = $active;
  
      return $this;
  }
  
  /**
   * Get active
   *
   * @return integer
   */
  public function getActive()
  {
      return $this-&gt;active;
  }
  
  /**
   * Set code2
   *
   * @param string $code2
   *
   * @return Countries
   */
  public function setCode2($code2)
  {
      $this-&gt;code2 = $code2;
  
      return $this;
  }
  
  /**
   * Get code2
   *
   * @return string
   */
  public function getCode2()
  {
      return $this-&gt;code2;
  }
  
  /**
   * Set code3
   *
   * @param string $code3
   *
   * @return Countries
   */
  public function setCode3($code3)
  {
      $this-&gt;code3 = $code3;
  
      return $this;
  }
  
  /**
   * Get code3
   *
   * @return string
   */
  public function getCode3()
  {
      return $this-&gt;code3;
  }
  
  /**
   * Set continents
   *
   * @param \DataBaseBundle\Entity\Continents $continents
   *
   * @return Countries
   */
  public function setContinents(\DataBaseBundle\Entity\Continents $continents = null)
  {
      $this-&gt;continents = $continents;
  
      return $this;
  }
  
  /**
   * Get continents
   *
   * @return \DataBaseBundle\Entity\Continents
   */
  public function getContinents()
  {
      return $this-&gt;continents;
  }
  
  /**
   * Set translation
   *
   * @param \DataBaseBundle\Entity\Translation $translation
   *
   * @return Countries
   */
  public function setTranslation(\DataBaseBundle\Entity\Translation $translation = null)
  {
      $this-&gt;translation = $translation;
  
      return $this;
  }
  
  /**
   * Get translation
   *
   * @return \DataBaseBundle\Entity\Translation
   */
  public function getTranslation()
  {
  
  
         return $this-&gt;translation;
      }
  }
  </code></pre>