8000 documenting choice_lazy option · symfony/symfony-docs@e55e7cd · GitHub
[go: up one dir, main page]

Skip to content

Commit e55e7cd

Browse files
committed
documenting choice_lazy option
1 parent 52d4f7b commit e55e7cd

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

reference/forms/types/choice.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ correct types will be assigned to the model.
178178

179179
.. include:: /reference/forms/types/options/choice_loader.rst.inc
180180

181+
.. include:: /reference/forms/types/options/choice_lazy.rst.inc
182+
181183
.. include:: /reference/forms/types/options/choice_name.rst.inc
182184

183185
.. include:: /reference/forms/types/options/choice_translation_domain_enabled.rst.inc
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.
28+
29+
.. versionadded:: 7.2
30+
31+
The ``choice_lazy`` option was introduced in Symfony 7.2.

0 commit comments

Comments
 (0)
0