File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,24 @@ good idea to include this in your form tag:
192192
193193 <form action="{{ path('form_submit') }}" method="post" {{ form_enctype(form) }}>
194194
195+ Form Tests Reference
196+ --------------------
197+
198+ Tests can be executed by using the ``is `` operator in Twig to create a
199+ condition. Read `the Twig documentation `_ for more information.
200+
201+ .. _form-twig-selectedchoice :
202+
203+ selectedchoice(selected_value)
204+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205+
206+ This test will check if the current choice is equal to the ``selected_value ``
207+ or if the current choice is in the array (when ``selected_value `` is an array).
208+
209+ .. code-block :: jinja
210+
211+ <option {% if choice is selectedchoice(value) %} selected="selected"{% endif %} ...>
212+
195213 .. _`twig-reference-form-variables` :
196214
197215More about Form Variables
@@ -357,3 +375,4 @@ object:
357375+------------------------+-------------------------------------------------------------------------------------+
358376
359377.. _`form_div_layout.html.twig` : https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
378+ .. _`the Twig documentation` : http://twig.sensiolabs.org/doc/templates.html#test-operator
You can’t perform that action at this time.
0 commit comments