title: How do I stop Symfony 2 checkbox from returning null
body: <p>On my Symfony 2 form I have 2 checkboxes. The documentation states </p>
  
  <blockquote>
    <p>"if the box is checked, the field will be set to true, if the box is
    unchecked, the value will be set to false"</p>
  </blockquote>
  
  <p>which is what I'd like to happen but when the checkbox is unchecked I'm actually getting nothing back. I realise a checkbox on a HTML form will normally return nothing if unchecked and I'd usually add some logic to the back end to handle it but it sounds like Symfony should be doing that for me and isn't.</p>
  
  <p>What am I doing wrong or have I missed?</p>
  
  <p>My formtype looks like this:</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder-&gt;add('fullname', 'text')
              -&gt;add('screened', 'checkbox', array(
                  'label'     =&gt; 'Enable screening emails?' ))
              -&gt;add('dedupe', 'checkbox', array(
                  'label'     =&gt; 'Enable live dedupeing?'))
   );)
  </code></pre>
  
  <p>and  the relevant bits of the twig template look like this:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;div class="input-group col-sm-offset-2 col-sm-10"&gt;
          &lt;div class="checkbox col-sm-6"&gt;
              {{ form_widget(form.screened) }}
              {{ form_label(form.screened) }}
          &lt;/div&gt;
          &lt;div class="checkbox col-sm-6"&gt;
              {{ form_widget(form.dedupe, {'attr': {'required': 'false'}}) }}
              {{ form_label(form.dedupe) }}
          &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The form is created in the controler here:</p>
  
  <pre><code>/**
       * Creates a new User entity.
       *
       */
      public function createAction(Request $request)
      {
          $entity = new User();
          $form = $this-&gt;createCreateForm($entity);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $this-&gt;get('project_login.user_manager')-&gt;setUserPassword($entity, $form-&gt;get('password')-&gt;getData());
  
              $em-&gt;persist($entity);
              $em-&gt;flush();
  
              return $this-&gt;redirect($this-&gt;generateUrl('user_show', array('id' =&gt; $entity-&gt;getId())));
          }
  
          return $this-&gt;render('ProjectLoginBundle:User:new.html.twig', array(
              'entity' =&gt; $entity,
              'form'   =&gt; $form-&gt;createView(),
          ));
      }
  
      /**
       * Creates a form to create a User entity.
       *
       * @param User $entity The entity
       *
       * @return \Symfony\Component\Form\Form The form
       */
      private function createCreateForm(User $entity)
      {
          $form = $this-&gt;createForm(new UserType(), $entity, array(
              'action' =&gt; $this-&gt;generateUrl('user_create'),
              'method' =&gt; 'POST', 'validation_groups' =&gt; array('create')
          ));
  
          $form-&gt;add('submit', 'submit', array('label' =&gt; 'Create'));
  
          return $form;
      }
  </code></pre>