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-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -941,19 +941,18 @@ Additionally, if there are any fields on the form that aren't included in
941
941
the submitted data, those fields will be explicitly set to ``null``.
942
942
943
943
Extra fields
944
-
~~~~~~~~~~~~~~~
944
+
~~~~~~~~~~~~
945
945
946
-
All form fields are considered properties of the object but you can inject fields
947
-
directly into your view without specifying them in the form definition.
948
-
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
946
+
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.
947
+
They can be retrieved via the ``getExtraData`` :class:`Symfony\\Component\\Form\\FormTypeInterface`.
949
948
950
949
This is a creation user form::
951
950
952
951
// ...
952
+
use App\User;
953
953
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
954
954
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
955
955
use Symfony\Component\Form\FormBuilderInterface;
956
-
use App\User;
957
956
958
957
class UserCreateType extends AbstractType
959
958
{
@@ -973,7 +972,9 @@ This is a creation user form::
973
972
}
974
973
}
975
974
976
-
The extra fields can be injected like this::
975
+
The extra fields can be injected like this:
976
+
977
+
.. code-block:: twig
977
978
978
979
{# templates/user/create.html.twig #}
979
980
{{ form_start(form) }}
@@ -988,7 +989,7 @@ The extra fields can be injected like this::
988
989
989
990
Here, the sponsorship code is an extra field injected at view level.
990
991
991
-
You can get the referraCode via ``getExtraData``::
992
+
You can get the referraCode via ``getExtraData``::
0 commit comments