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

[Form] Document using TranslatableMessage for label and choice_label#16717

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

Merged
javiereguiluz merged 1 commit intosymfony:5.4fromSebLevDev:feature/translatablemessage_inf_form_fields
Jun 18, 2022
Merged
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
1 change: 1 addition & 0 deletionsreference/forms/types/options/choice_label.rst.inc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ more control::

// or if you want to translate some key
//return 'form.choice.'.$key;
//return new TranslatableMessage($key, false === $choice ? [] : ['%status%' => $value], 'store');
},
]);

Expand Down
20 changes: 18 additions & 2 deletionsreference/forms/types/options/label.rst.inc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
``label``
~~~~~~~~~

**type**: ``string`` **default**: The label is "guessed" from the field name
**type**: ``string``or ``TranslatableMessage``**default**: The label is "guessed" from the field name

Sets the label that will be used when rendering the field. Setting to ``false``
will suppress the label. The label can also be set in the template:
will suppress the label.

use Symfony\Component\Translation\TranslatableMessage;

$builder
->add('zipCode', null, [
'label' => 'The ZIP/Postal code',
])

// ...

->add('zipCode', null, [
'label' => new TranslatableMessage('address.zipCode', ['%country%' => $country], 'address'),
])
;

The label can also be set in the template:

.. configuration-block::

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp