Skip to content

Commit ac9fbcd

Browse files
committed
updated the way form errors are customized
1 parent 6e7c0cd commit ac9fbcd

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

cookbook/form/form_customization.rst

+4-23
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,9 @@ and customize the ``form_errors`` fragment.
718718
{% block form_errors %}
719719
{% spaceless %}
720720
{% if errors|length > 0 %}
721-
<ul class="error_list">
721+
<ul>
722722
{% for error in errors %}
723-
<li>{{
724-
error.messagePluralization is null
725-
? error.messageTemplate|trans(error.messageParameters, 'validators')
726-
: error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
727-
}}</li>
723+
<li>{{ error.message }}</li>
728724
{% endfor %}
729725
</ul>
730726
{% endif %}
@@ -735,28 +731,13 @@ and customize the ``form_errors`` fragment.
735731

736732
<!-- form_errors.html.php -->
737733
<?php if ($errors): ?>
738-
<ul class="error_list">
734+
<ul>
739735
<?php foreach ($errors as $error): ?>
740-
<li><?php
741-
if (null === $error->getMessagePluralization()) {
742-
echo $view['translator']->trans(
743-
$error->getMessageTemplate(),
744-
$error->getMessageParameters(),
745-
'validators'
746-
);
747-
} else {
748-
echo $view['translator']->transChoice(
749-
$error->getMessageTemplate(),
750-
$error->getMessagePluralization(),
751-
$error->getMessageParameters(),
752-
'validators'
753-
);
754-
}?></li>
736+
<li><?php echo $error->getMessage() ?></li>
755737
<?php endforeach; ?>
756738
</ul>
757739
<?php endif ?>
758740

759-
760741
.. tip::
761742

762743
See :ref:`cookbook-form-theming-methods` for how to apply this customization.

cookbook/validation/custom_constraint.rst

-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ The validator class is also simple, and only has one required method: ``validate
7979
The first parameter of the ``addViolation`` call is the error message to
8080
use for that violation.
8181

82-
.. versionadded:: 2.1
83-
The ``isValid`` method was renamed to ``validate`` in Symfony 2.1. The
84-
``setMessage`` method was also deprecated, in favor of calling ``addViolation``
85-
on the context.
86-
8782
Using the new Validator
8883
-----------------------
8984

0 commit comments

Comments
 (0)