title: Symfony2 repeated type does not validate
body: <p>I have two password fields. That extra is for confirmation.
  And there is no error message when both are empty or when passwords don't match.</p>
  
  <p>How to enable or debug this validation which I presume should be working out of the box (<a href="http://symfony.com/doc/current/reference/forms/types/repeated.html#validation" rel="nofollow">http://symfony.com/doc/current/reference/forms/types/repeated.html#validation</a>)?</p>
  
  <pre><code>class MyType extends AbstractType
  {
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'My\\Bundle\\Entity\\User',
          ));
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          ...
          $builder-&gt;add('password', 'repeated', array(
              'invalid_message' =&gt; 'Passwords must match.',
              'type'            =&gt; 'password',
              'required'        =&gt; true,
              'first_options'   =&gt; array('label' =&gt; 'Password'),
              'second_options'  =&gt; array('label' =&gt; 'Repeat Password')
          ));
  </code></pre>
  
  <p><strong>form.html.twig</strong></p>
  
  <pre><code>...
  &lt;form action="" method="post" novalidate&gt;
  ...
  &lt;tr&gt;
      &lt;td&gt;{{ form_label(regForm.password.first) }}&lt;/td&gt;
      &lt;td&gt;{{ form_widget(regForm.password.first, { 'attr': {'pattern': '.{6,}','title': 'Minimum 6 characters long'} } ) }}&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;{{ form_label(regForm.password.second) }}&lt;/td&gt;
      &lt;td&gt;{{ form_widget(regForm.password.second, { 'attr': {'pattern': '.{6,}', 'title': 'Minimum 6 characters long', 'data-equals': '#register_password_first'} } ) }}&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Validators declared in <strong>validation.yml</strong> seem to have no effect on the issue.</p>
  
  <pre><code>My\Bundle\Entity\User:
      properties:
          ...
          password:
              # this one does not work because of "repeated" type in buildForm()???
                  - NotBlank:
                      message: "Password is required."
                  - MinLength:
                      limit: 6
                      message: "Password must have at least {{ limit }} characters."
  </code></pre>
  
  <p><strong>Controller.php</strong> (original version)</p>
  
  <pre><code>...
  if (!$form-&gt;isValid()) {
      $formFields = $form-&gt;all();
      foreach ($formFields as $key =&gt; $field) {
          if ($field-&gt;getErrorsAsString()) {
              $errors = $field-&gt;getErrors();
              foreach ($errors as $error) {
                  $messages[$key][] = $error-&gt;getMessage();
              }
          }
      }
      var_dump($messages);
  </code></pre>
  
  <p><strong>EDIT</strong>: Now errors retrieval looks like this (thanks to alex.dominte):</p>
  
  <pre><code>public static function getFormErrorMessages(\Symfony\Component\Form\Form $form)
  {
      $messages = array();
  
      foreach ($form-&gt;getErrors() as $i =&gt; $error) {
          $messages[$i] = $error-&gt;getMessage();
      }
  
      foreach ($form-&gt;all() as $child) {
          if (!$child-&gt;isValid()) {
              $messages[$child-&gt;getName()] = self::getFormErrorMessages($child);
          }
      }
  
      return $messages;
  }
  </code></pre>
  
  <p>Modifications suggested by Pedro Cordeiro make it possible to drop recursion but also make field names unavailable.</p>