From 2336e887679f87ee993e386fae177eb6c1b3aeb0 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 22 May 2016 14:02:56 -0400 Subject: [PATCH] Trying to remove some duplication and some extra details --- reference/forms/types/entity.rst | 37 ++++++-------------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 2a9da6976f2..bb73ca7958c 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -194,39 +194,16 @@ return a ``QueryBuilder``. Overridden Options ------------------ -choice_name -~~~~~~~~~~~ +.. include:: /reference/forms/types/options/choice_name.rst.inc -.. versionadded:: 2.7 - The ``choice_name`` option was introduced in Symfony 2.7. - -**type**: ``string``, ``callable`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: id - -By default the name of each field is the id of the entity, if it can be read -from the class metadata by an internal id reader. Otherwise the process will -fall back to using increasing integers. - -choice_value -~~~~~~~~~~~~ +In the ``EntityType``, this defaults to the ``id`` of the entity, if it can +be read. Otherwise, it falls back to using auto-incrementing integers. -.. versionadded:: 2.7 - The ``choice_value`` option was introduced in Symfony 2.7. - -**type**: ``string``, ``callable`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: id - -As for the ``choice_name`` option, ``choice_value`` uses the id by default. -It allows an optimization in the :class:``Symfony\\Bridge\\Doctrine\\Form\\ChoiceList\\Loader\\DoctrineChoiceLoader`` which will -only load the ids passed as values while the form submission. -It prevents all non submitted entities to be loaded from the database, even -when defining the ``query_builder`` option. -If it may be useful to set this option using an entity's property as string -value (e.g for some API), you will gain performances by letting this option set -by default. - -.. note:: +.. include:: /reference/forms/types/options/choice_value.rst.inc - If the id cannot be read, for BC, the component checks if the class implements - ``__toString()`` and will use an incremental integer otherwise. +In the ``EntityType``, this is overridden to use the ``id`` by default. When the +``id`` is used, Doctrine only queries for the objects for the ids that were actually +submitted. choices ~~~~~~~