Skip to content

add separate placeholder examples for birthday, datetime and time type #6206

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
25 changes: 24 additions & 1 deletion reference/forms/types/birthday.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,30 @@ type:

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

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

.. versionadded:: 2.6
The ``placeholder`` option was introduced in Symfony 2.6 and replaces
``empty_value``, which is available prior to 2.6.

**type**: ``string`` or ``array``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use string`` | ``array instead of "or" in the rest of the reference as far as I know.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. It was only used in the DateType placeholder documentation.


If your widget option is set to ``choice``, then this field will be represented
as a series of ``select`` boxes. The ``placeholder`` option can be used
to add a "blank" entry to the top of each select box::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this a bit more generic saying something like "when the placeholder is a string, it will be used as the blank value of all select boxes: [....] Alternatively, you can use an array that configures different placeholder values for the day, month and year fields."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the text from the DateType placeholder documentation.
I can change this for the 4 different types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would a good idea as it makes things a bit more clear.


$builder->add('birthdate', 'birthday', array(
'placeholder' => '',
));

Alternatively, you can specify a string to be displayed for the "blank" value::

$builder->add('birthdate', 'birthday', array(
'placeholder' => array(
'year' => 'Year', 'month' => 'Month', 'day' => 'Day',
)
));

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

Expand Down
26 changes: 25 additions & 1 deletion reference/forms/types/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,31 @@ date_widget

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

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

.. versionadded:: 2.6
The ``placeholder`` option was introduced in Symfony 2.6 and replaces
``empty_value``, which is available prior to 2.6.

**type**: ``string`` or ``array``

If your widget option is set to ``choice``, then this field will be represented
as a series of ``select`` boxes. The ``placeholder`` option can be used
to add a "blank" entry to the top of each select box::

$builder->add('startDateTime', 'datetime', array(
'placeholder' => '',
));

Alternatively, you can specify a string to be displayed for the "blank" value::

$builder->add('startDateTime', 'datetime', array(
'placeholder' => array(
'year' => 'Year', 'month' => 'Month', 'day' => 'Day',
'hour' => 'Hour', 'minute' => 'Minute', 'second' => 'Second',
)
));

format
~~~~~~
Expand Down
25 changes: 24 additions & 1 deletion reference/forms/types/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,30 @@ values.
Field Options
-------------

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

.. versionadded:: 2.6
The ``placeholder`` option was introduced in Symfony 2.6 and replaces
``empty_value``, which is available prior to 2.6.

**type**: ``string`` or ``array``

If your widget option is set to ``choice``, then this field will be represented
as a series of ``select`` boxes. The ``placeholder`` option can be used
to add a "blank" entry to the top of each select box::

$builder->add('startTime', 'time', array(
'placeholder' => '',
));

Alternatively, you can specify a string to be displayed for the "blank" value::

$builder->add('startTime', 'time', array(
'placeholder' => array(
'hour' => 'Hour', 'minute' => 'Minute', 'second' => 'Second',
)
));

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

Expand Down