symfony: [Form] No error message in repeating fields

//...
$builder->add('password','repeated',array(
  'type' => 'password',
  'error_bubbling' => true,
  'invalid_message' => 'Sample invalid message',
));
//...

When I send the form via AJAX request, and check the validity of the form, the error message does not appear for repeating fields.

//...
$form->bind($request);
if($form->isValid()) {
  //...some stuff
} else {
  //check validation
  $errors = $form->getErrors();

  $message = '';

  foreach($errors as $error) {
    $message .= '- ' . $error->getMessageTemplate() . '<br />';
  }
  //when password and repeat password fields are not equal, invalid message is not shown in $message
}
//...

Regards, Andrew.

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Comments: 36 (11 by maintainers)

Most upvoted comments

$form->get('password')->get('first')->addError(new FormError('Oops! This is a error message for first field of RepeatedField '));

$form->get('password')->get('second')->addError(new FormError('Oops! This is error message for confirm field'));

works for me 😄