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: forms.rst
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -950,7 +950,8 @@ the submitted data, those fields will be explicitly set to ``null``.
950
950
Extra fields
951
951
~~~~~~~~~~~~
952
952
953
-
All form fields are considered properties of the object but you can inject fields directly into your view without specifying them in the form definition.
953
+
All form fields are considered properties of the object but you can inject
954
+
fields directly into your view without specifying them in the form definition.
954
955
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
955
956
956
957
This is a creation user form::
@@ -999,6 +1000,14 @@ Here, the referral code is an extra field injected at view level.
999
1000
The field name is composed of form ``user_create`` and the field name ``referralCode``.
1000
1001
It's automatically generated from the form class name. You can :ref:`override it <changing-the-form-name>`
1001
1002
1003
+
Or you can use use
1004
+
.. code-block:: html+twig
1005
+
{{ form.vars.full_name ~ '[referralCode]' }}
1006
+
1007
+
to render the form name dynamically
1008
+
1009
+
{{ form.vars.full_name ~ '[description]' }}
1010
+
1002
1011
You can get the referral code via ``getExtraData``::
0 commit comments