Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions reference/forms/types/options/choice_loader.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ This will cause the call of ``StaticClass::getConstants()`` to not happen if the
request is redirected and if there is no pre set or submitted data. Otherwise
the choice options would need to be resolved thus triggering the callback.

If the ``CallbackChoiceLoader`` doesn't fit your needs and you want to create
your own loader, you can either create a loader by implementing the
:class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
or by extending the
:class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader`.
This abstract class allows to save some boilerplate by implementing some
of the :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`
methods. Thus, you'll only have to implement the
:method:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader::loadChoices`
method to have a fully functional choice loader.

.. versionadded:: 5.1

The :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\AbstractChoiceLoader`
class was introduced in Symfony 5.1.

When you're defining a custom choice type that may be reused in many fields
(like entries of a collection) or reused in multiple forms at once, you
should use the :class:`Symfony\\Component\\Form\\ChoiceList\\ChoiceList`
Expand Down