Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Documented label_format option#4489

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
wouterj wants to merge1 commit intosymfony:2.6fromwouterj:issue_4286
Closed
Show file tree
Hide file tree
Changes fromall 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
3 changes: 3 additions & 0 deletionsreference/forms/types/checkbox.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@ if the box is unchecked, the value will be set to false.
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -70,6 +71,8 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/choice.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ option.
| | - `inherit_data`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -180,6 +181,8 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/collection.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ forms, which is useful when creating forms that expose one-to-many relationships
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `required`_ |
+-------------+-----------------------------------------------------------------------------+
Expand DownExpand Up@@ -383,6 +384,8 @@ error_bubbling

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

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

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

.. include:: /reference/forms/types/options/required.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/country.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,7 @@ you should just use the ``choice`` type directly.
| | - `empty_data`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -100,6 +101,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/currency.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ should just use the ``choice`` type directly.
| | - `empty_data`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -90,6 +91,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/email.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ The ``email`` field is a text field that is rendered using the HTML5
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `read_only`_ |
Expand DownExpand Up@@ -53,6 +54,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/max_length.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/entity.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@ objects from the database.
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -240,6 +241,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/file.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ The ``file`` type represents a file input in your form.
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -116,6 +117,8 @@ The default value is ``null``.

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/form.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@ on all types for which ``form`` is the parent type.
| | - `invalid_message`_ |
| | - `invalid_message_parameters`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `method`_ |
Expand DownExpand Up@@ -94,6 +95,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. _reference-form-option-max_length:
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/integer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down (e.g. 6
| | - `invalid_message_parameters`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -102,6 +103,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/language.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,6 +42,7 @@ you should just use the ``choice`` type directly.
| | - `empty_data`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -101,6 +102,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/locale.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,6 +44,7 @@ you should just use the ``choice`` type directly.
| | - `empty_data`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -103,6 +104,8 @@ The actual default value of this option depends on other field options:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/money.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ how the input and output of the data is handled.
| | - `invalid_message_parameters`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -112,6 +113,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/number.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ you want to use for your number.
| | - `invalid_message_parameters`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -98,6 +99,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
30 changes: 30 additions & 0 deletionsreference/forms/types/options/label_format.rst.inc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
label_format
~~~~~~~~~~~~

.. versionadded:: 2.6
The ``label_format`` option was introduced in Symfony 2.6.

**type**: ``string`` **default**: ``null``

This allows to change the label for a field. You have access to 2 variables:
``%name%`` and ```%id%``. The ``%id%`` is unique for each field and contains
the complete path to and the field name, the ``%name%`` contains just the field
name.

When using translation keys as labels, you often end up with duplicated labels.
For instance, ``registration_first_name`` and ``profile_first_name``. To avoid
this, you can use the label format::

// ...
$formBuilder
->add('registration', new RegistrationType(), array(
'label_format' => 'form.person.%name%',
))
->add('profile', new ProfileType(), array(
'label_format' => 'form.person.%name%',
))
;

The option is inherited to the child types. With the code above, the
``first_name`` field of both forms will have the ``form.person.first_name``
label.
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

it found it a very difficult option to describe, I'm open for other suggestions!

3 changes: 3 additions & 0 deletionsreference/forms/types/password.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ The ``password`` field renders an input password text box.
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `read_only`_ |
Expand DownExpand Up@@ -68,6 +69,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/max_length.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/percent.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,7 @@ This field adds a percentage sign "``%``" after the input box.
| | - `invalid_message_parameters`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -95,6 +96,8 @@ The default value is ``''`` (the empty string).

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/radio.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ If you want to have a Boolean field, use :doc:`checkbox </reference/forms/types/
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `read_only`_ |
| | - `required`_ |
Expand DownExpand Up@@ -61,6 +62,8 @@ These options inherit from the :doc:`form </reference/forms/types/form>` type:

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

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

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

.. include:: /reference/forms/types/options/read_only.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/search.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ Read about the input search field at `DiveIntoHTML5.info`_
| | - `error_mapping`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `label_format`_ |
| | - `mapped`_ |
| | - `max_length`_ (deprecated as of 2.5) |
| | - `read_only`_ |
Expand DownExpand Up@@ -52,6 +53,8 @@ The default value is ``''`` (the empty string).

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

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

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

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

[8]ページ先頭

©2009-2025 Movatter.jp