title: Symfony 2.8 - how to create "terms & conditions" check-box which isn't mapped to the underlying model
body: <p>I'm using Symfony 2.8 and I'm trying to create a registration form containing a "terms &amp; conditions" check-box which isn't mapped to the underlying data model.</p>
  
  <p>I've followed this cookbook article:
  <a href="http://symfony.com/doc/current/cookbook/doctrine/registration_form.html#adding-a-accept-terms-checkbox" rel="nofollow noreferrer">How to Implement a Simple Registration Form</a></p>
  
  <p>Everything in the form validation works, except for the the "terms &amp; conditions" check-box. After submitting the form, the check-box validation doesn't get triggered.</p>
  
  <p>This is my code:</p>
  
  <pre><code>namespace Likestripe\AdminBundle\Form\Type;
  
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
  use Symfony\Component\Validator\Constraints\IsFalse;
  use Symfony\Component\Validator\Constraints\IsTrue;
  
  
  class RegistrationFormType extends AbstractType { //BaseType
  
  /**
   * @param FormBuilderInterface $builder
   * @param array $options
   */
  public function buildForm(FormBuilderInterface $builder, array $options) {
      // call parent constructor
      //parent::buildForm($builder, $options);
  
      // add your custom fields
      $builder-&gt;add('salutation', ChoiceType::class,   array('choices'  =&gt;   array('Herr' =&gt; 0, 'Frau' =&gt; 1), 'choices_as_values' =&gt; true));
      $builder-&gt;add('firstname',  TextType::class,     array());
      $builder-&gt;add('lastname',   TextType::class,     array());
      $builder-&gt;remove('username');
      $builder-&gt;add('company',    new CompanyFormType());
      $builder-&gt;add('conditions', CheckboxType::class, array('mapped' =&gt; false, 'constraints' =&gt; new IsTrue(array("message" =&gt; "Bitte akzeptieren Sie noch die AGB und Nutzungsbedingungen."))));
      $builder-&gt;add('submit',     SubmitType::class,   array('label' =&gt; 'Registrieren'));
  } // end function
  
  
  public function getParent() {
      return 'FOS\UserBundle\Form\Type\RegistrationFormType';
  
      // Or for Symfony &lt; 2.8
      // return 'fos_user_registration';
  }
  
  /**
   * function deprecated since 2.8 https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form
   *
   * @return string
   */
  public function getName() {
      //return 'likestripe_user_registration';
      return $this-&gt;getBlockPrefix();
  } // end function
  
  public function getBlockPrefix() {
      return 'likestripe_user_registration';
  }
  
  } // end class
  </code></pre>
  
  <p>I can't see any difference between my code and the code demonstrated in the cookbook article.</p>
  
  <p>Screen capture of my Symfony debug console:
  <a href="https://i.stack.imgur.com/To45J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/To45J.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>As Kamil proposed, I've checked if the 'conditions' check-box form parameter gets posted after submitting the form.<br />
  The param gets posted als long as the check-box is checked, but if not, the "conditions" form parameter doesn't get posted at all... this behavior reminds me of <a href="https://stackoverflow.com/questions/1809494/post-the-checkboxes-that-are-unchecked">this case</a>.</p>
  
  <p>I'm still wondering why the <a href="http://symfony.com/doc/current/cookbook/doctrine/registration_form.html#adding-a-accept-terms-checkbox" rel="nofollow noreferrer">official Symfony documentation</a> proposes a isTrue Validator which doesn't seem to be the solution to check for an unchecked check-box, any suggestions how to fix this?</p>
  
  <p><strong>Checkbox checked:</strong>
  <a href="https://i.stack.imgur.com/Mbz2c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mbz2c.png" alt="enter image description here"></a></p>
  
  <p><strong>Checkbox unchecked:</strong>
  <a href="https://i.stack.imgur.com/i14sA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i14sA.png" alt="enter image description here"></a></p>
  
  <p>Thanks in advance for your help<br>
  ninsky</p>