Skip to content

Commit 0978b97

Browse files
committed
feature #19246 [Form] Document using TranslatableMessage in form Fields (SebLevDev)
This PR was merged into the 5.4 branch. Discussion ---------- [Form] Document using TranslatableMessage in form Fields Document using TranslatableMessage for button_label and placeholder like form help (#15527) #SymfonyHackday Commits ------- 5ac1a00 [Form] Document using TranslatableMessage in form Fields
2 parents 0d192c7 + 5ac1a00 commit 0978b97

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

reference/forms/types/options/button_label.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``label``
22
~~~~~~~~~
33

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

66
Sets the label that will be displayed on the button. The label can also
77
be directly set inside the template:

reference/forms/types/options/placeholder.rst.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``placeholder``
22
~~~~~~~~~~~~~~~
33

4-
**type**: ``string`` or ``boolean``
4+
**type**: ``string`` or ``TranslatableMessage`` or ``boolean``
55

66
This option determines whether or not a special "empty" option (e.g. "Choose
77
an option") will appear at the top of a select widget. This option only
@@ -14,6 +14,9 @@ applies if the ``multiple`` option is set to false.
1414

1515
$builder->add('states', ChoiceType::class, [
1616
'placeholder' => 'Choose an option',
17+
18+
// or if you want to translate the text
19+
'placeholder' => new TranslatableMessage('form.placeholder.select_option', [], 'form'),
1720
]);
1821

1922
* Guarantee that no "empty" value option is displayed::

0 commit comments

Comments
 (0)