From 8656f759b54bc31ffba8d6cc2fba03f0f2c1b854 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 18 Nov 2014 20:02:57 +0100 Subject: [PATCH] Documented label_format option --- reference/forms/types/checkbox.rst | 3 ++ reference/forms/types/choice.rst | 3 ++ reference/forms/types/collection.rst | 3 ++ reference/forms/types/country.rst | 3 ++ reference/forms/types/currency.rst | 3 ++ reference/forms/types/email.rst | 3 ++ reference/forms/types/entity.rst | 3 ++ reference/forms/types/file.rst | 3 ++ reference/forms/types/form.rst | 3 ++ reference/forms/types/integer.rst | 3 ++ reference/forms/types/language.rst | 3 ++ reference/forms/types/locale.rst | 3 ++ reference/forms/types/money.rst | 3 ++ reference/forms/types/number.rst | 3 ++ .../forms/types/options/label_format.rst.inc | 30 +++++++++++++++++++ reference/forms/types/password.rst | 3 ++ reference/forms/types/percent.rst | 3 ++ reference/forms/types/radio.rst | 3 ++ reference/forms/types/search.rst | 3 ++ reference/forms/types/submit.rst | 3 ++ reference/forms/types/text.rst | 3 ++ reference/forms/types/textarea.rst | 3 ++ reference/forms/types/timezone.rst | 3 ++ reference/forms/types/url.rst | 3 ++ 24 files changed, 99 insertions(+) create mode 100644 reference/forms/types/options/label_format.rst.inc diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index eeddb8031de..6610dde5ebb 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -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`_ | @@ -70,6 +71,8 @@ These options inherit from the :doc:`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 diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index a5757116817..75327d6b7e3 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -31,6 +31,7 @@ option. | | - `inherit_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -180,6 +181,8 @@ These options inherit from the :doc:`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 diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 2d21cf57a3a..412939ffb92 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -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`_ | +-------------+-----------------------------------------------------------------------------+ @@ -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 diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index c50ac519a48..d687e732447 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -41,6 +41,7 @@ you should just use the ``choice`` type directly. | | - `empty_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index f009d726993..35c3d7cff60 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -34,6 +34,7 @@ should just use the ``choice`` type directly. | | - `empty_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index d6277f5bee9..2d36911a02b 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 17728fa3be9..b3e7dc4037d 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -38,6 +38,7 @@ objects from the database. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index 2449a4fdc92..0f93ed6898d 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index ae0f66edcc0..24c8daa7dfd 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -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`_ | @@ -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: diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index edf9e9c1b9b..7e73c1d0d2e 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 120cb37b11c..45af9e35896 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -42,6 +42,7 @@ you should just use the ``choice`` type directly. | | - `empty_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index e8610495901..26a80dcea06 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -44,6 +44,7 @@ you should just use the ``choice`` type directly. | | - `empty_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 6db6ead9c06..c1c569f19bf 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 29f4edfaf2e..3b61e16da56 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -24,6 +24,7 @@ you want to use for your number. | | - `invalid_message_parameters`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -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 diff --git a/reference/forms/types/options/label_format.rst.inc b/reference/forms/types/options/label_format.rst.inc new file mode 100644 index 00000000000..3c65a4c9446 --- /dev/null +++ b/reference/forms/types/options/label_format.rst.inc @@ -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. diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index a7d605883ad..fedb01930a5 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 253a43c69b5..481a721bcfd 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index 2bf650dc027..9de3de92bb0 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -28,6 +28,7 @@ If you want to have a Boolean field, use :doc:`checkbox ` 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 diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index c9c9890d490..3419ed4d482 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -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`_ | @@ -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 diff --git a/reference/forms/types/submit.rst b/reference/forms/types/submit.rst index 63385eb328c..1891ac8a1ff 100644 --- a/reference/forms/types/submit.rst +++ b/reference/forms/types/submit.rst @@ -16,6 +16,7 @@ A submit button. | options | - `disabled`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `translation_domain`_ | | | - `validation_groups`_ | +----------------------+----------------------------------------------------------------------+ @@ -44,6 +45,8 @@ Inherited Options .. include:: /reference/forms/types/options/label_attr.rst.inc +.. include:: /reference/forms/types/options/label_format.rst.inc + .. include:: /reference/forms/types/options/button_translation_domain.rst.inc validation_groups diff --git a/reference/forms/types/text.rst b/reference/forms/types/text.rst index 5fb4f07ae34..aa2ebe1f078 100644 --- a/reference/forms/types/text.rst +++ b/reference/forms/types/text.rst @@ -16,6 +16,7 @@ The text field represents the most basic input text field. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `max_length`_ (deprecated as of 2.5) | | | - `read_only`_ | @@ -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 diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index a75ffbb0f27..71765bd2f7b 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -17,6 +17,7 @@ Renders a ``textarea`` HTML element. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `max_length`_ (deprecated as of 2.5) | | | - `read_only`_ | @@ -55,6 +56,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 diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 175345b0330..4fcfc5e7c56 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -37,6 +37,7 @@ you should just use the ``choice`` type directly. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -96,6 +97,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 diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index ace61dd0588..6e715661df8 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -20,6 +20,7 @@ have a protocol. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `max_length`_ (deprecated as of 2.5) | | | - `read_only`_ | @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy