title: Load choices into form choice field from entity method
body: <p>I have symfony form with choice field. I want to load choices from my entity class static method. can i use data or CallbackChoiceLoader? what is the best practise?</p>
  
  <p>this is my field:</p>
  
  <pre><code>        class CarType extends AbstractType
  {
  public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('type', ChoiceType::class, [
              // This choices I would like to load from:
              // 'choices' =&gt; $car::getTypes(),
              'choices'       =&gt; [
                  'Critical'  =&gt; 'critical',
                  'Medium'    =&gt; 'medium',
                  'Info'      =&gt; 'info',
              ],
              'label'         =&gt; 'Type'
          ])
          -&gt;add('name', TextType::class, [
              'label' =&gt; 'Name'
          ])
          -&gt;add('save', SubmitType::class, [
              'label' =&gt; 'Save'
          ])
      ;
  }
  
  public function configureOptions(OptionsResolver $resolver)
  {
      $resolver-&gt;setDefaults([
          'data_class' =&gt; 'AppBundle\Entity\Car'
      ]);
  }
  
  public function getName()
  {
      return 'car';
  }
  }
  </code></pre>
  
  <p>This is my entity:</p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="car")
   */
  class Car
  {
  /**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer", nullable=false)
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="IDENTITY")
   */
  private $id;
  
  /**
   * @var string $type
   *
   * @Assert\NotBlank()
   * @ORM\Column(name="type")
   */
  private $type;
  
  /**
   * @var string $name
   *
   * @Assert\NotBlank()
   * @ORM\Column(name="name")
   */
  private $name;
  
  /**
   * @var \DateTime $created
   *
   * @ORM\Column(name="created", type="datetime")
   */
  private $created;
  
  private static $types = ['main', 'custom'];
  
  public function __construct()
  {
      $this-&gt;created = new \DateTime('now', new \DateTimeZone('Europe/Ljubljana'));
  }
  
  /**
   * Get id
   *
   * @return integer
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Get types
   * 
   * @return array
   */
  public function getTypes()
  {
      return self::$types;
  }
  
  /**
   * Set type
   *
   * @param string $type
   *
   * @return Car
   */
  public function setType($type)
  {
      if (in_array($type, $this-&gt;getTypes())) {
          $this-&gt;type = $type;
      }
  
      return $this;
  }
  
  /**
   * Get type
   *
   * @return string
   */
  public function getType()
  {
      return $this-&gt;type;
  }
  
  /**
   * Set name
   *
   * @param string $name
   *
   * @return Car
   */
  public function setName($name)
  {
      $this-&gt;name = $name;
  
      return $this;
  }
  
  /**
   * Get name
   *
   * @return string
   */
  public function getName()
  {
      return $this-&gt;name;
  }
  
  /**
   * Set created
   *
   * @param \DateTime $created
   *
   * @return Car
   */
  public function setCreated($created)
  {
      $this-&gt;created = $created;
  
      return $this;
  }
  
  /**
   * Get created
   *
   * @return \DateTime
   */
  public function getCreated()
  {
      return $this-&gt;created;
  }
  </code></pre>
  
  <p>How and what can i use to load choices from $car::getTypes() method like i commented in form so that the choices are loaded dynamicly based on values in getTypes entity method?</p>