title: Symfony form with EntityType field yields a 'This value should not be blank' error if the field has a Valid() contraint in the object class
body: <p>I have a <code>Phone</code> class and a <code>Country</code> class in a Symfony 2.8 project.
  One of the fields of the <code>Phone</code> class is <code>$country</code> which is a <code>Country</code> object.</p>
  
  <p>I also have a form with an EntityType field, which I use to select from a list of the countries in my database.</p>
  
  <p>My problem is that when I select a country from the dropdown menu generated by the EntityType field and submit the form, I get the error 'This value should not be blank.' several times above the EntityField dropdown menu.</p>
  
  <p>What is weird is that I do a <code>dump($phone)</code> after <code>$form-&gt;handleRequest($request);</code> and the $country field shows the correct Country object fetched from the database.</p>
  
  <p>This only happens when the <code>@Assert\Valid()</code> constraint is on the <code>$country</code> field. Once i remove it the error goes away.
  The thing is that I want to continue to validate the country field of my <code>Phone</code> class.</p>
  
  <p>Any ideas on why this is happening would be greatly appreciated!</p>
  
  <p><code>Phone</code> class:
      
  
  <pre><code>namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * Phone
   *
   * @ORM\Table(name="phones", uniqueConstraints={@ORM\UniqueConstraint(name="natural_pk", columns={"phone_name", "country_id", "phone_number", "extension"})})
   * @ORM\Entity(repositoryClass="AppBundle\Repository\PhoneRepository")
   * @ORM\HasLifecycleCallbacks
   */
  class Phone
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       *
       * @Assert\Type(type="int")
       */
      protected $id;
  
      /**
       * @var Country
       *
       * @ORM\ManyToOne(targetEntity="Country")
       * @ORM\JoinColumn(nullable=false)
       *
       * @Assert\NotBlank()
       * @Assert\Valid()
       */
      protected $country;
  
      /**
       * @var string
       *
       * @ORM\Column(name="phone_number", type="string", length=20, nullable=false)
       *
       * @Assert\NotBlank()
       * @Assert\Type(type="string")
       * @Assert\Length(max=20)
       */
      protected $phoneNumber;
  
      public function __toString()
      {
          return $this-&gt;phoneNumber;
      }
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set phoneNumber
       *
       * @param string $phoneNumber
       *
       * @return Phone
       */
      public function setPhoneNumber($phoneNumber)
      {
          $this-&gt;phoneNumber = $phoneNumber;
  
          return $this;
      }
  
      /**
       * Get phoneNumber
       *
       * @return string
       */
      public function getPhoneNumber()
      {
          return $this-&gt;phoneNumber;
      }
  
      /**
       * Set country
       *
       * @param \AppBundle\Entity\Country $country
       *
       * @return Phone
       */
      public function setCountry(\AppBundle\Entity\Country $country)
      {
          $this-&gt;country = $country;
  
          return $this;
      }
  
      /**
       * Get country
       *
       * @return \AppBundle\Entity\Country
       */
      public function getCountry()
      {
          return $this-&gt;country;
      }
  }
  </code></pre>
  
  <p>Country class:
      
  
  <pre><code>namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * Country
   *
   * @ORM\Table(name="countries")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\CountryRepository")
   */
  class Country
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       *
       * @Assert\Type(type="int")
       */
      protected $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="country_name", type="string", length=255, nullable=false)
       *
       * @Assert\NotBlank()
       * @Assert\Type(type="string")
       * @Assert\Length(max=255)
       */
      protected $countryName;
  
      /**
       * @var string
       *
       * @ORM\Column(name="phone_code", type="string", length=10, nullable=false)
       *
       * @Assert\NotBlank()
       * @Assert\Type(type="string")
       * @Assert\Length(max=10)
       */
      protected $phoneCode;
  
      public function __toString()
      {
          return $this-&gt;phoneCode;
      }
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set countryName
       *
       * @param string $countryName
       *
       * @return Country
       */
      public function setCountryName($countryName)
      {
          $this-&gt;countryName = $countryName;
  
          return $this;
      }
  
      /**
       * Get countryName
       *
       * @return string
       */
      public function getCountryName()
      {
          return $this-&gt;countryName;
      }
  
      /**
       * Set phoneCode
       *
       * @param string $phoneCode
       *
       * @return Country
       */
      public function setPhoneCode($phoneCode)
      {
          $this-&gt;phoneCode = $phoneCode;
  
          return $this;
      }
  
      /**
       * Get phoneCode
       *
       * @return string
       */
      public function getPhoneCode()
      {
          return $this-&gt;phoneCode;
      }
  }
  </code></pre>