Skip to content

Commit

Permalink
minor #17469 [Form] Add a placeholder_attr option to ChoiceType (…
Browse files Browse the repository at this point in the history
…elementaire)

This PR was merged into the 6.3 branch.

Discussion
----------

[Form] Add a `placeholder_attr` option to `ChoiceType`

PR symfony/symfony#48343

Commits
-------

8fcd394 Add a placeholder_attr option to ChoiceType
  • Loading branch information
javiereguiluz committed Jun 6, 2023
2 parents 3be5f6a + 8fcd394 commit 5e68a2a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ correct types will be assigned to the model.

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

Overridden Options
Expand Down Expand Up @@ -295,6 +297,8 @@ Field Variables
| placeholder | ``mixed`` | The empty value if not already in the list, otherwise |
| | | ``null``. |
+----------------------------+--------------+-------------------------------------------------------------------+
| placeholder_attr | ``array`` | The value of the `placeholder_attr`_ option. |
+----------------------------+--------------+-------------------------------------------------------------------+
| choice_translation_domain | ``mixed`` | ``boolean``, ``null`` or ``string`` to determine if the value |
| | | should be translated. |
+----------------------------+--------------+-------------------------------------------------------------------+
Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ Doctrine's Array Collection.

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

``preferred_choices``
~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ If you return ``null``, the option won't be grouped.

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down
2 changes: 2 additions & 0 deletions reference/forms/types/locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down
21 changes: 21 additions & 0 deletions reference/forms/types/options/placeholder_attr.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
``placeholder_attr``
~~~~~~~~~~~~~~~~~~~~

**type**: ``array`` **default**: ``[]``

Use this to add additional HTML attributes to the placeholder choice::

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// ...

$builder->add('fruits', ChoiceType::class, [
// ...
'placeholder' => '...',
'placeholder_attr' => [
['title' => 'Choose an option'],
],
]);

.. versionadded:: 6.3

The ``placeholder_attr`` option was introduced in Symfony 6.3.
2 changes: 2 additions & 0 deletions reference/forms/types/timezone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/placeholder.rst.inc

.. include:: /reference/forms/types/options/placeholder_attr.rst.inc

.. include:: /reference/forms/types/options/preferred_choices.rst.inc

.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
Expand Down

0 comments on commit 5e68a2a

Please sign in to comment.