title: Delete FOSUserBundle error messages
body: <p>i'm trying to remove from my form the generic FOSUserBundle message.</p>
  
  <p>That is the result when i've an error : 
  <img src="https://i.stack.imgur.com/qPJZN.png" alt="enter image description here"></p>
  
  <p>i want to remove the message in the red square.
  And as you can see i succeeded to ad my own error message.</p>
  
  <p>I checked a ton of other forum without success.</p>
  
  <p>Here is my code :</p>
  
  <ul>
  <li><p>app/MDBUserBundle/views/Registration/register_content.html ( i overrided the register form)</p>
  
  <pre><code> {% trans_default_domain 'FOSUserBundle' %}
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <pre><code>    &lt;div class="form-group"&gt; 
      &lt;label for={{ form.username.vars.id }}&gt;Pseudo&lt;/label&gt;
  {{ form_widget(form.username,{'attr': {'class': 'form-control' , 'placeholder':'Entrez votre pseudo'}}) }}
  {{ form_errors(form.username) }}
  &lt;/div&gt;
  &lt;div class="form-group"&gt; 
      &lt;label for={{ form.email.vars.id }}&gt;Adresse e-mail&lt;/label&gt;
  {{ form_widget(form.email , {'attr': {'class': 'form-control' , 'placeholder':'Entrez votre adresse mail'}}) }}
  {{ form_errors(form.email) }}
      &lt;/div&gt;
      &lt;div class="form-group"&gt; 
          &lt;label for={{ form.plainPassword.first.vars.id }}&gt;Mot de passe&lt;/label&gt;
  {{ form_widget(form.plainPassword.first,{'attr': {'class': 'form-control' , 'placeholder':'Entrez votre mot de passe'}}) }}
  {{ form_errors(form.plainPassword.first) }}
  &lt;/div&gt;
  &lt;div class="form-group"&gt; 
      &lt;label for={{ form.plainPassword.second.vars.id }}&gt;Confirmation du mot de passe&lt;/label&gt;
   {{ form_widget(form.plainPassword.second,{'attr': {'class': 'form-control' , 'placeholder':'Confirmez votre mot de passe'}}) }}
      &lt;/div&gt;
      {{ form_rest(form) }}
      &lt;div&gt;
      &lt;input type="submit" class="btn btn-default" value="Enregistrer" /&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  </code></pre></li>
  <li><p>in MDB/USerBundle/Type/RegistrationFormType.php</p>
  
  <pre><code>&lt;?php
  
  namespace MDB\UserBundle\Form\Type;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  
  class RegistrationFormType extends AbstractType {
  
  public function buildForm(FormBuilderInterface $builder, array $options) {
  
      parent::buildForm($builder, $options);
  
      // Ajoutez vos champs ici, revoilà notre champ *location* :
  
  }
  
  public function getParent() {
      return 'fos_user_registration';
  }
  
  public function getName() {
      return 'mdb_user_registration';
  }
  
  } 
  ?&gt;
  </code></pre></li>
  <li><p>in MDB/UserBundle/Validator/Constraints</p></li>
  </ul>
  
  <p>ContainsUser.php </p>
  
  <p>
  
  <pre><code>namespace MDB\UserBundle\Validator\Constraints;
  
  use Symfony\Component\Validator\Constraint;
  
  /**
   * @Annotation
   */
  class ContainsUser extends Constraint {
  
      public $message = 'L\'utilisateur "%string%" exist déja.';
  
      public function validatedBy() {
          return 'contains_user';
      }
  
      public function getTargets() {
          return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT);
      }
  
  }
  </code></pre>
  
  <p>ContainsUserValidator.php</p>
  
  <pre><code>&lt;?php
  namespace MDB\UserBundle\Validator\Constraints;
  
  use Symfony\Component\Validator\Constraint;
  use Symfony\Component\Validator\ConstraintValidator;
  
  class ContainsUserValidator extends ConstraintValidator
  {
      protected $em;
  
      public function __construct(\Doctrine\ORM\EntityManager $em)
      {
          $this-&gt;em = $em;
      }
  public function validate($value, Constraint $constraint)
      {
          $repository     = $this-&gt;em-&gt;getRepository('MDBUserBundle:User');
          $user           = $repository-&gt;findOneByUsername($value);
  
          if ($user) {
              $this-&gt;context-&gt;addViolation(
                  $constraint-&gt;message,
                  array('%string%' =&gt; $value)
              );
  }}}
  </code></pre>
  
  <ul>
  <li>in MDN.UserBundle</li>
  </ul>
  
  <p>MDBUserBundle.php</p>
  
  <pre><code>&lt;?php
  
  namespace MDB\UserBundle;
  
  use Symfony\Component\HttpKernel\Bundle\Bundle;
  
  class MDBUserBundle extends Bundle {
  
  public function getParent()
      {
          return 'FOSUserBundle';
      }
  }
  </code></pre>
  
  <ul>
  <li>in MDB/UserBundle/Ressources/config</li>
  </ul>
  
  <p>validation.xml</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
  
  http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"&gt;
  
      &lt;class name="FOS\UserBundle\Model\User"&gt;
  
          &lt;property name="username"&gt;
              &lt;constraint name="NotBlank"&gt;
                  &lt;option name="message"&gt;fos_user.username.blank&lt;/option&gt;
                  &lt;option name="groups"&gt;
                      &lt;value&gt;Registration&lt;/value&gt;
                      &lt;value&gt;Profile&lt;/value&gt;
                  &lt;/option&gt;
              &lt;/constraint&gt;
              &lt;constraint name="MDB\UserBundle\Validator\Constraints\ContainsUser"&gt;             
                  &lt;option name="groups"&gt;
                      &lt;value&gt;Registration&lt;/value&gt;
                      &lt;value&gt;Profile&lt;/value&gt;
                  &lt;/option&gt;                
              &lt;/constraint&gt;     
  
              &lt;constraint name="Length"&gt;
                  &lt;option name="min"&gt;4&lt;/option&gt;
                  &lt;option name="minMessage"&gt;fos_user.username.short&lt;/option&gt;
                  &lt;option name="max"&gt;20&lt;/option&gt;
                  &lt;option name="maxMessage"&gt;fos_user.username.long&lt;/option&gt;
                  &lt;option name="groups"&gt;
                      &lt;value&gt;Registration&lt;/value&gt;
                      &lt;value&gt;Profile&lt;/value&gt;
                  &lt;/option&gt;
              &lt;/constraint&gt;
  
  
  
          &lt;/property&gt;
      &lt;/class&gt;
  
  &lt;/constraint-mapping&gt;
  </code></pre>
  
  <p>services.yml</p>
  
  <pre><code>services:
      mdb_user.registration.form.type:
          class: MDB\UserBundle\Form\Type\RegistrationFormType
          tags:
              - { name: form.type, alias: mdb_user_registration }
  
      mdb.user.validator.contains_user:
          class: MDB\UserBundle\Validator\Constraints\ContainsUserValidator
          arguments: [ "@doctrine.orm.entity_manager" ]       
          tags:
              - { name: validator.constraint_validator, alias: contains_user } 
  
      mdb_user.registration_complet:
          class: MDB\UserBundle\EventListener\RegistrationConfirmListener
          arguments: ["@router"]
          tags:
              - { name: kernel.event_subscriber }
  </code></pre>
  
  <p>So if you have an idea to remove these messages it will be great :)</p>
  
  <p>Thanks in advance</p>