Open youuri opened 12 years ago
@youuri Simply add the below to your controller and pass it down to the view
private function getErrorMessages(Form $form)
{
$errors = [];
foreach ($form->getErrors() as $key => $error) {
if ($form->isRoot()) {
$errors['#'][] = $error->getMessage();
} else {
$errors[] = $error->getMessage();
}
}
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getErrorMessages($child);
}
}
return $errors;
}
hi,
I'm working on registration form and i have some problems with errors messages after validation. I'm using a "form_theme" and all errors form registration form are displaying as a global error form and not as a field error.
{# Form Theme Row #############################################################} {% block field_row %} {% spaceless %}
{% endspaceless %} {% endblock field_row %}
{% block field_rows %} {% spaceless %}
{% endspaceless %} {% endblock field_rows %}
Is it possible to configure validator or an other way to put error as field-error and not global-error?
Best regards