diff --git a/components/translation/usage.rst b/components/translation/usage.rst index 3cf13b9fb7d..eab38dc1b80 100644 --- a/components/translation/usage.rst +++ b/components/translation/usage.rst @@ -139,6 +139,8 @@ recommended format. These files are parsed by one of the loader classes. 'symfony.great' => 'J\'aime Symfony', ); +.. _translation-real-vs-keyword-messages: + .. sidebar:: Using Real or Keyword Messages This example illustrates the two different philosophies when creating diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index b0c657a2add..69b5670c42b 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -22,6 +22,7 @@ true, if the box is unchecked, the value will be set to false. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -71,6 +72,8 @@ 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 1d37c9c6f6f..a5ad07341b0 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -37,6 +37,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | | - `inherit_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -337,6 +338,8 @@ 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 6bd1e0282d5..b5036c7785f 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -29,6 +29,7 @@ photos). | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `required`_ | +-------------+-----------------------------------------------------------------------------+ @@ -389,6 +390,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 557f497676c..405e598362b 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`_ | @@ -102,6 +103,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 2d2f4748106..2a8dffd71e5 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -34,6 +34,7 @@ you should just use the ``choice`` type directly. | | - `empty_data`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -92,6 +93,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 0d6f548a033..ee174e6922c 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`_ | @@ -54,6 +55,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 01ce0f7862d..9c2d9c5aa43 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -37,6 +37,7 @@ objects from the database. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -243,6 +244,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 aac88bc7627..d946dfde4f7 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -20,6 +20,7 @@ The ``file`` type represents a file input in your form. | | - `error_mapping`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -125,6 +126,8 @@ 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/form.rst b/reference/forms/types/form.rst index 66ba30ca19c..a2ed009fb9d 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -24,6 +24,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`_ | @@ -110,6 +111,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 + .. _reference-form-option-mapped: .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 1b32e43b3f5..70c2e1561fa 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -32,6 +32,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down | | - `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/language.rst b/reference/forms/types/language.rst index dd00048f977..8f43a6bcc3c 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`_ | @@ -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/locale.rst b/reference/forms/types/locale.rst index 2a723382d4e..1fc34fc1520 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`_ | @@ -105,6 +106,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 ae322be16f6..68fa455909b 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -31,6 +31,7 @@ how the input and output of the data is handled. | | - `invalid_message_parameters`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -125,6 +126,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 a60746824b0..937a6ff6fd4 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -27,6 +27,7 @@ that you want to use for your number. | | - `invalid_message_parameters`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -107,6 +108,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..73f7eee0e7e --- /dev/null +++ b/reference/forms/types/options/label_format.rst.inc @@ -0,0 +1,47 @@ +label_format +~~~~~~~~~~~~ + +.. versionadded:: 2.6 + The ``label_format`` option was introduced in Symfony 2.6. + +**type**: ``string`` **default**: ``null`` + +Configures the string used as the label of the field, in case the ``label`` +option was not set. This is useful when using +:ref:`keyword translation messages `. + +If you're using keyword translation messages as labels, you often end up having +multiple keyword messages for the same label (e.g. ``profile_address_street``, +``invoice_address_street``). This is because the label is build for each "path" +to a field. To avoid duplicated keyword messages, you can configure the label +format to a static value, like:: + + // ... + $profileFormBuilder->add('address', new AddressType(), array( + 'label_format' => 'form.address.%name%', + )); + + $invoiceFormBuilder->add('invoice', new AddressType(), array( + 'label_format' => 'form.address.%name%', + )); + +This option is inherited by the child types. With the code above, the label of +the ``street`` field of both forms will use the ``form.address.street`` keyword +message. + +Two variables are available in the label format: + +``%id%`` + A unique identifier for the field, consisting of the complete path to the + field and the field name (e.g. ``profile_address_street``); +``%name%`` + The field name (e.g. ``street``). + +The default value (``null``) results in a +:ref:`"humanized" version ` of the field name. + +.. note:: + + The ``label_format`` option is evaluated in the form theme. Make sure to + update your templates in case you + :doc:`customized form theming `. diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 137d0c70dcc..4c2b4eb3bff 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -20,6 +20,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`_ | @@ -83,6 +84,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 843b65f66f2..a96cb1258eb 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -30,6 +30,7 @@ This field adds a percentage sign "``%``" after the input box. | | - `invalid_message_parameters`_ | | | - `label`_ | | | - `label_attr`_ | +| | - `label_format`_ | | | - `mapped`_ | | | - `read_only`_ | | | - `required`_ | @@ -109,6 +110,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 771f5b13490..2f6f3926f22 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -29,6 +29,7 @@ If you want to have a boolean field, use :doc:`checkbox `". Filters ------- +.. _reference-twig-humanize-filter: + humanize ~~~~~~~~ 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