Skip to content

Commit 0b0164f

Browse files
committed
[#772] Adding more details on rendering the repeated form field type
1 parent 95582d6 commit 0b0164f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

reference/forms/types/repeated.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,44 @@ the actual type of the two underlying fields. The ``options`` option is passed
4747
to each of those individual fields, meaning - in this example - any option
4848
supported by the ``password`` type can be passed in this array.
4949

50+
Rendering
51+
~~~~~~~~~
52+
53+
The repeated field type is actually two underlying fields, which you can
54+
render all at once, or individually. To render all at once, use something
55+
like:
56+
57+
.. configuration-block::
58+
59+
.. code-block:: jinja
60+
61+
{{ form_row(form.password) }}
62+
63+
.. code-block:: php
64+
65+
<?php echo $view['form']->row($form['password']) ?>
66+
67+
To render each field individually, use something like this:
68+
69+
.. configuration-block::
70+
71+
.. code-block:: jinja
72+
73+
{{ form_errors(form.password) }}
74+
{{ form_row(form.password.first) }}
75+
{{ form_row(form.password.second) }}
76+
77+
.. code-block:: php
78+
79+
<?php echo $view['form']->errors($form['password']) ?>
80+
<?php echo $view['form']->row($form['password']['first']) ?>
81+
<?php echo $view['form']->row($form['password']['second']) ?>
82+
83+
.. note::
84+
85+
The sub-field names are ``first`` and ``second`` by default, but can
86+
be controlled via the `first_name`_ and `second_name`_ options.
87+
5088
Validation
5189
~~~~~~~~~~
5290

0 commit comments

Comments
 (0)