File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ correct types will be assigned to the model.
178
178
179
179
.. include :: /reference/forms/types/options/choice_loader.rst.inc
180
180
181
+ .. include :: /reference/forms/types/options/choice_lazy.rst.inc
182
+
181
183
.. include :: /reference/forms/types/options/choice_name.rst.inc
182
184
183
185
.. include :: /reference/forms/types/options/choice_translation_domain_enabled.rst.inc
Original file line number Diff line number Diff line change
1
+ ``choice_lazy``
2
+ ~~~~~~~~~~~~~~~
3
+
4
+ **type**: ``boolean`` **default**: ``false``
5
+
6
+ The ``choice_lazy`` option is especially useful when dealing with a large set of
7
+ choices, where loading all of them at once could lead to performance issues or
8
+ significant delays::
9
+
10
+ use App\Entity\User;
11
+ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
12
+
13
+ $builder->add('user', EntityType::class, [
14
+ 'class' => User::class,
15
+ 'choice_lazy' => true,
16
+ ]);
17
+
18
+ When set to ``true``, and used in combination with the ``choice_loader`` option,
19
+ the form will only load and render the choices that are preset as default values
20
+ or submitted. This allows you to defer loading the full list of choices and can
21
+ improve the performance of your form.
22
+
23
+ .. caution::
24
+
25
+ Please note that when using ``choice_lazy``, you are responsible for providing
26
+ the user interface to select choices, typically through a JavaScript plugin that
27
+ can handle the dynamic loading of choices.
You can’t perform that action at this time.
0 commit comments