-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #5642 Documented label_format option (WouterJ)
This PR was merged into the 2.7 branch. Discussion ---------- Documented label_format option | Q | A | --- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#12050) | Applies to | 2.6+ | Fixed tickets | #4286 @javiereguiluz abandoned #4412, so I continued #4489. I welcome any improvements, as I'm not 100% sure this is well documented now. Commits ------- ac0fdbc Documented label_format option
- Loading branch information
Showing
26 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <translation-real-vs-keyword-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 <reference-twig-humanize-filter>` 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 </cookbook/form/form_customization>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.