title: Symfony3.0 When saving a form with Entity Type dropdown; SQL error cannot insert null
body: <p>Using Symfony 3.0, I have a form with a dropdown list generated from a Doctrine Entity. When I complete the form &amp; Submit I can see in the profiler that the dropdown value has been passed through correctly, yet I get the following error:
  Any idea what might be happening?  <em>EDIT</em> I am not wanting to pass a null value. The form is passing in the selected value from the entity dropdown. But the insert into the db doesn't seem to be using this?</p>
  
  <pre><code>SQLSTATE[23000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot
  insert the value NULL into column 'account_type', table 'CRM.dbo.accounts';
  column does not allow nulls. INSERT fails.
  </code></pre>
  
  <p>The form is: (AccountType.php) </p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('accountTypeId', EntityType::class, array(
              'class' =&gt; 'AppBundle:AccountType',
              'choice_label' =&gt; 'typeName',
              //'label' =&gt; 'Account Type',
          ))
          -&gt;add('name')
          -&gt;add('notes', null, array('label' =&gt; 'Long Name', 'required' =&gt; false))
          -&gt;add('address')
          -&gt;add('city')
          -&gt;add('region')
          -&gt;add('country', CountryType::class)
          -&gt;add('postcode')
          -&gt;add('telephone', null, array('required' =&gt; false))
          -&gt;add('website', null, array('required' =&gt; false))
          -&gt;add('email', null, array('required' =&gt; false))
          -&gt;add('save', SubmitType::class);
  }
  </code></pre>
  
  <p>Controller: (AccountController.php)</p>
  
  <pre><code>public function addAction(Request $request)
  {
      $account = new Account();
  
      $form = $this-&gt;createForm(AccountType::class, $account);
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
          try {
              // create account
              //$account = $form-&gt;getData();
  
              // save data to db
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($account);
              $em-&gt;flush();
  
              // add flash message and return to profile
              $this-&gt;addFlash('success', 'Account: ' . $account-&gt;getName() .' created successfully.');
  
              return $this-&gt;redirectToRoute('accounts');
          }
          catch(Exception $e) {
              $this-&gt;addFlash('error', $e-&gt;getMessage());
  
              return $this-&gt;redirectToRoute('accounts');
          }
      }
  
      // load form for new account
      return $this-&gt;render('accounts/add.html.twig', array(
          'form' =&gt; $form-&gt;createView()
      ));
  
  }
  </code></pre>
  
  <p>Account Model relation: </p>
  
  <pre><code>/**
   * @ORM\ManyToOne(targetEntity="AccountType", inversedBy="accounts")
   * @ORM\JoinColumn(name="account_type", referencedColumnName="id")
   */
  private $accountTypeName;
  </code></pre>
  
  <p>AccountType Model relation:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Account", mappedBy="accountTypeName")
   */
  private $accounts;
  </code></pre>