File tree 2 files changed +35
-0
lines changed
Filter options
2 files changed +35
-0
lines changed
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
18
18
| | - `choice_label `_ |
19
19
| | - `choice_loader `_ |
20
20
| | - `choice_name `_ |
21
+ | | - `choice_translation_parameters `_ |
21
22
| | - `choice_translation_domain `_ |
22
23
| | - `choice_value `_ |
23
24
| | - `expanded `_ |
@@ -225,6 +226,8 @@ correct types will be assigned to the model.
225
226
226
227
.. include :: /reference/forms/types/options/choice_name.rst.inc
227
228
229
+ .. include :: /reference/forms/types/options/choice_translation_parameters.rst.inc
230
+
228
231
.. include :: /reference/forms/types/options/choice_translation_domain.rst.inc
229
232
230
233
.. include :: /reference/forms/types/options/choice_value.rst.inc
Original file line number Diff line number Diff line change
1
+ choice_translation_parameters
2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
+
4
+ **type**: ``array`` **default**: ``[]``
5
+
6
+ The choice values are translated before displaying it, so it can contain
7
+ :ref:`translation placeholders <component-translation-placeholders>`.
8
+ This option defines the values used to replace those placeholders.
9
+
10
+ Given this translation message:
11
+
12
+ .. code-block:: yaml
13
+
14
+ # translations/messages.en.yaml
15
+ form.order.yes: 'I confirm my order to the company %company%'
16
+ form.order.no: 'I cancel my order to the company %company%'
17
+
18
+ You can specify the placeholder values as follows::
19
+
20
+ $builder->add('id', null, [
21
+ 'choice' => [
22
+ 'form.order.yes' => true,
23
+ 'form.order.no' => false,
24
+ ],
25
+ 'choice_translation_parameters' => [
26
+ '%company%' => 'ACME Inc.',
27
+ ],
28
+ ]);
29
+
30
+ The ``choice_translation_parameters`` option of children fields is merged with
31
+ the same option of their parents, so children can reuse and/or override any of
32
+ the parent placeholders.
You can’t perform that action at this time.
0 commit comments