Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "property" option of DoctrineType was deprecated. #5499

Merged
merged 1 commit into from
Jul 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ objects from the database.
+-------------+------------------------------------------------------------------+
| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) |
+-------------+------------------------------------------------------------------+
| Options | - `class`_ |
| Options | - `choice_label`_ |
| | - `class`_ |
| | - `data_class`_ |
| | - `em`_ |
| | - `group_by`_ |
| | - `property`_ |
| | - `query_builder`_ |
+-------------+------------------------------------------------------------------+
| Overridden | - `choice_list`_ |
Expand Down Expand Up @@ -55,13 +55,13 @@ be listed inside the choice field::

$builder->add('users', 'entity', array(
'class' => 'AcmeHelloBundle:User',
'property' => 'username',
'choice_label' => 'username',
));

In this case, all ``User`` objects will be loaded from the database and
rendered as either a ``select`` tag, a set or radio buttons or a series
of checkboxes (this depends on the ``multiple`` and ``expanded`` values).
If the entity object does not have a ``__toString()`` method the ``property``
If the entity object does not have a ``__toString()`` method the ``choice_label``
option is needed.

Using a Custom Query for the Entities
Expand Down Expand Up @@ -103,6 +103,29 @@ then you can supply the ``choices`` option directly::
Field Options
-------------

choice_label
~~~~~~~~~~~~

**type**: ``string``

This is the property that should be used for displaying the entities
as text in the HTML element. If left blank, the entity object will be
cast into a string and so must have a ``__toString()`` method.

.. note::

The ``choice_label`` option is the property path used to display the option.
So you can use anything supported by the
:doc:`PropertyAccessor component </components/property_access/introduction>`

For example, if the translations property is actually an associative
array of objects, each with a name property, then you could do this::

$builder->add('gender', 'entity', array(
'class' => 'MyBundle:Gender',
'choice_label' => 'translations[en].name',
));

class
~~~~~

Expand Down Expand Up @@ -133,29 +156,6 @@ and does so by adding ``optgroup`` elements around options. Choices that
do not return a value for this property path are rendered directly under
the select tag, without a surrounding optgroup.

property
~~~~~~~~

**type**: ``string``

This is the property that should be used for displaying the entities
as text in the HTML element. If left blank, the entity object will be
cast into a string and so must have a ``__toString()`` method.

.. note::

The ``property`` option is the property path used to display the option.
So you can use anything supported by the
:doc:`PropertyAccessor component </components/property_access/introduction>`

For example, if the translations property is actually an associative
array of objects, each with a name property, then you could do this::

$builder->add('gender', 'entity', array(
'class' => 'MyBundle:Gender',
'property' => 'translations[en].name',
));

query_builder
~~~~~~~~~~~~~

Expand Down