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
+8-7
Original file line number
Diff line number
Diff line change
@@ -948,19 +948,18 @@ Additionally, if there are any fields on the form that aren't included in
948
948
the submitted data, those fields will be explicitly set to ``null``.
949
949
950
950
Extra fields
951
-
~~~~~~~~~~~~~~~
951
+
~~~~~~~~~~~~
952
952
953
-
All form fields are considered properties of the object but you can inject fields
954
-
directly into your view without specifying them in the form definition.
955
-
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
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.
954
+
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
956
955
957
956
This is a creation user form::
958
957
959
958
// ...
959
+
use App\User;
960
960
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
961
961
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
962
962
use Symfony\Component\Form\FormBuilderInterface;
963
-
use App\User;
964
963
965
964
class UserCreateType extends AbstractType
966
965
{
@@ -980,7 +979,9 @@ This is a creation user form::
980
979
}
981
980
}
982
981
983
-
The extra fields can be injected like this::
982
+
The extra fields can be injected like this:
983
+
984
+
.. code-block:: twig
984
985
985
986
{# templates/user/create.html.twig #}
986
987
{{ form_start(form) }}
@@ -995,7 +996,7 @@ The extra fields can be injected like this::
995
996
996
997
Here, the sponsorship code is an extra field injected at view level.
997
998
998
-
You can get the referraCode via ``getExtraData``::
999
+
You can get the referraCode via ``getExtraData``::
0 commit comments