Skip to content

Commit da531f3

Browse files
committed
minor #18804 [Form] Added AbstractChoiceLoader (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Form] Added `AbstractChoiceLoader` Fix #13120 If this [one's closed](#12826 (comment)), then this is the last one of the 5.1 milestone 😄 Commits ------- 37c4df7 [Form] Added `AbstractChoiceLoader`
2 parents f0c591f + 37c4df7 commit da531f3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

reference/forms/types/options/choice_loader.rst.inc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ This will cause the call of ``StaticClass::getConstants()`` to not happen if the
2626
request is redirected and if there is no pre set or submitted data. Otherwise
2727
the choice options would need to be resolved thus triggering the callback.
2828

29+
If the ``CallbackChoiceLoader`` doesn't fit your needs and you want to create
30+
your own loader, you can either create a loader by implementing the
31+
:class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
32+
or by extending the
33+
:class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader`.
34+
This abstract class allows to save some boilerplate by implementing some
35+
of the :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
36+
methods. Thus, you'll only have to implement the
37+
:method:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader::loadChoices`
38+
method to have a fully functional choice loader.
39+
40+
.. versionadded:: 5.1
41+
42+
The :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader`
43+
class was introduced in Symfony 5.1.
44+
2945
When you're defining a custom choice type that may be reused in many fields
3046
(like entries of a collection) or reused in multiple forms at once, you
3147
should use the :class:`Symfony\\Component\\Form\\ChoiceList\\ChoiceList`

0 commit comments

Comments
 (0)