title: How to add an error to a constraint in form?
body: <p>Using Symfony 3.2 on Ubuntu 16.04</p>
  
  <p>I created a FormType.php with several fields. One of them is a phone number, so I added a constraint where only numbers could be accepted. Here is the code for the phone form</p>
  
  <pre><code>-&gt;add('authorPhone', NumberType::class, array('label' =&gt; 'Numéro de téléphone',
                  'required' =&gt; true,
                  'attr' =&gt; array(
                      'class' =&gt; 'validate',
                      'id' =&gt; 'icon_telephone'
                  ),
                  'constraints' =&gt; array(new Regex("#^0[1-9]([-. ]?[0-9]{2}){4}$#"))
              ))
  </code></pre>
  
  <p>After that, in my controller I added an error to tell that numbers only need to be filled in</p>
  
  <pre><code>public function indexAction()
      {
          $form = $this-&gt;createForm(FormType::class);
          $form-&gt;get('authorPhone')-&gt;addError(new FormError('error message'));
  
          return $this-&gt;render('app/main/index.html.twig', array(
              'form' =&gt; $form-&gt;createView()
          ));
      }
  </code></pre>
  
  <p>But when I look at my page the error message is actually showing without having filled the field. And of course I don't want that.</p>
  
  <p><a href="https://i.stack.imgur.com/6J11O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6J11O.png" alt="image"></a></p>
  
  <p>(you can see under "Numéro de téléphone", which means phone number)</p>
  
  <p>I only want numbers in my phone number field, and if there are letters, an error should be displayed or something saying it's not right.</p>