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: docs/customization/form.rst
+22-15Lines changed: 22 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,11 @@ You can:
19
19
How to customize a Form?
20
20
~~~~~~~~~~~~~~~~~~~~~~~~
21
21
22
+
.. tip::
23
+
24
+
You can browse the full implementation of this example on GitHub
25
+
on the `<https://github.com/Sylius/Customizations/pull/8>`_
26
+
22
27
If you want to modify the form for the ``Customer Profile`` in your system there are a few steps that you should take.
23
28
Assuming that you would like to (for example):
24
29
@@ -58,9 +63,6 @@ As a result you will get the ``Sylius\Bundle\CustomerBundle\Form\Type\CustomerPr
58
63
59
64
final class CustomerProfileTypeExtension extends AbstractTypeExtension
60
65
{
61
-
/**
62
-
* {@inheritdoc}
63
-
*/
64
66
public function buildForm(FormBuilderInterface $builder, array $options): void
65
67
{
66
68
// Adding new fields works just like in the parent form type.
@@ -78,12 +80,9 @@ As a result you will get the ``Sylius\Bundle\CustomerBundle\Form\Type\CustomerPr
78
80
]);
79
81
}
80
82
81
-
/**
82
-
* {@inheritdoc}
83
-
*/
84
-
public function getExtendedType(): string
83
+
public static function getExtendedTypes(): iterable
85
84
{
86
-
return CustomerProfileType::class;
85
+
return [CustomerProfileType::class];
87
86
}
88
87
}
89
88
@@ -105,8 +104,8 @@ As a result you will get the ``Sylius\Bundle\CustomerBundle\Form\Type\CustomerPr
105
104
Of course remember that you need to render the new fields you have created,
106
105
and remove the rendering of the fields that you have removed **in your views**.
107
106
108
-
In our case you will need to copy the original template from `vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Account/profileUpdate.html.twig`
109
-
to `templates/bundles/SyliusShopBundle/Account/` and add the fields inside the copy
107
+
In our case you will need to copy the original template from ``vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Account/profileUpdate.html.twig``
108
+
to ``templates/bundles/SyliusShopBundle/Account/`` and add the fields inside the copy
110
109
111
110
.. code-block:: html
112
111
@@ -139,6 +138,14 @@ For instance the ``ProductVariant`` admin form is defined under ``Sylius/Bundle/
139
138
140
139
your form extension will also be executed. Whether before or after the other extensions depends on priority tag set.
141
140
141
+
How to customize a Form when form elements are embedded dynamically?
0 commit comments