You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/libraries/validation.rst
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -527,10 +527,12 @@ or the value that was validated you can add the ``{field}``, ``{param}`` and ``{
527
527
528
528
'min_length' => 'Supplied value ({value}) for {field} must have at least {param} characters.'
529
529
530
-
On a field with the human name Username and a rule of min_length[6] with a value of “Pizza”, an error would display: “Supplied value (Pizza) for Username must have
530
+
On a field with the human name Username and a rule of ``min_length[6]`` with a value of “Pizza”, an error would display: “Supplied value (Pizza) for Username must have
531
531
at least 6 characters.”
532
532
533
-
.. note:: If you pass the last parameter the labeled style error messages will be ignored.
533
+
.. warning:: If you get the error messages with ``getErrors()`` or ``getError()``, the messages are not HTML escaped. If you use user input data like ``({value})`` to make the error message, it might contain HTML tags. If you don't escape the messages before displying them, XSS attacks are possible.
534
+
535
+
.. note:: When using label-style error messages, if you pass the second parameter to ``setRules()``, it will be overwritten with the value of the first parameter.
534
536
535
537
Translation Of Messages And Validation Labels
536
538
=============================================
@@ -592,7 +594,7 @@ You can check to see if an error exists with the ``hasError()`` method. The only
592
594
}
593
595
594
596
Customizing Error Display
595
-
************************************************
597
+
*************************
596
598
597
599
When you call ``$validation->listErrors()`` or ``$validation->showError()``, it loads a view file in the background
598
600
that determines how the errors are displayed. By default, they display with a class of ``errors`` on the wrapping div.
@@ -643,11 +645,11 @@ short alias they can be referenced by. If we were to add our example file from a
643
645
Specifying the Template
644
646
=======================
645
647
646
-
You can specify the template to use by passing it's alias as the first parameter in ``listErrors``::
648
+
You can specify the template to use by passing it's alias as the first parameter in ``listErrors()``::
647
649
648
650
<?= $validation->listErrors('my_list') ?>
649
651
650
-
When showing field-specific errors, you can pass the alias as the second parameter to the ``showError`` method,
652
+
When showing field-specific errors, you can pass the alias as the second parameter to the ``showError()`` method,
651
653
right after the name of the field the error should belong to::
0 commit comments