Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit236d06b

Browse files
committed
Fix the definition of customizing form's global errors.
1 parentfc0aa8b commit236d06b

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

‎cookbook/form/form_customization.rst

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,40 @@ to just one field) are rendered separately, usually at the top of your form:
785785
<?php echo $view['form']->render($form); ?>
786786
787787
To customize *only* the markup used for these errors, follow the same directions
788-
as above, but now call the block ``form_errors`` (Twig) / the file ``form_errors.html.php``
789-
(PHP). Now, when errors for the ``form`` type are rendered, your customized
790-
fragment will be used instead of the default ``form_errors``.
788+
as above, but now check if the ``compound`` attribute is set to ``true``:
789+
790+
..configuration-block::
791+
792+
..code-block::html+jinja
793+
794+
{# form_errors.html.twig #}
795+
{% block form_errors %}
796+
{% spaceless %}
797+
{% if errors|length > 0 %}
798+
{% if compound %}
799+
<ul>
800+
{% for error in errors %}
801+
<li>{{ error.message }}</li>
802+
{% endfor %}
803+
</ul>
804+
{% endif %}
805+
{% endif %}
806+
{% endspaceless %}
807+
{% endblock form_errors %}
808+
809+
..code-block::html+php
810+
811+
<!-- form_errors.html.php -->
812+
<?php if ($errors): ?>
813+
<?php if ($compound): ?>
814+
<ul>
815+
<?php foreach ($errors as $error): ?>
816+
<li><?php echo $error->getMessage() ?></li>
817+
<?php endforeach; ?>
818+
</ul>
819+
<?php endif; ?>
820+
<?php endif ?>
821+
791822

792823
Customizing the "Form Row"
793824
~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp