Skip to content

Commit

Permalink
feature #5499 The "property" option of DoctrineType was deprecated. (…
Browse files Browse the repository at this point in the history
…XWB)

This PR was merged into the 2.7 branch.

Discussion
----------

The "property" option of DoctrineType was deprecated.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.7
| Fixed tickets | -

Commits
-------

cdb9067 The "property" option of DoctrineType was deprecated.
  • Loading branch information
wouterj committed Jul 23, 2015
2 parents 90745db + cdb9067 commit 3df5dd6
Showing 1 changed file with 27 additions and 27 deletions.
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

0 comments on commit 3df5dd6

Please sign in to comment.