Skip to content

Commit 9ef444b

Browse files
committed
Add dynamic form name
1 parent 391f99b commit 9ef444b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

forms.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ the submitted data, those fields will be explicitly set to ``null``.
950950
Extra fields
951951
~~~~~~~~~~~~
952952

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.
954955
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
955956

956957
This is a creation user form::
@@ -999,6 +1000,14 @@ Here, the referral code is an extra field injected at view level.
9991000
The field name is composed of form ``user_create`` and the field name ``referralCode``.
10001001
It's automatically generated from the form class name. You can :ref:`override it <changing-the-form-name>`
10011002

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+
10021011
You can get the referral code via ``getExtraData``::
10031012

10041013
$extraData = $form->getExtraData();

0 commit comments

Comments
 (0)