Skip to content

Commit 0a42ca7

Browse files
committed
Minor tweaks
1 parent fdc886a commit 0a42ca7

File tree

6 files changed

+79
-326
lines changed

6 files changed

+79
-326
lines changed

reference/forms/types/button.rst

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ A simple, non-responsive button.
1010
| Rendered as | ``button`` tag |
1111
+----------------------+----------------------------------------------------------------------+
1212
| Inherited | - `attr`_ |
13-
| options | - `disabled`_ |
13+
| options | - `attr_translation_parameters`_ |
14+
| | - `disabled`_ |
1415
| | - `label`_ |
15-
| | - `translation_domain`_ |
1616
| | - `label_translation_parameters`_ |
17-
| | - `attr_translation_parameters`_ |
17+
| | - `translation_domain`_ |
1818
+----------------------+----------------------------------------------------------------------+
1919
| Parent type | none |
2020
+----------------------+----------------------------------------------------------------------+
@@ -59,77 +59,37 @@ label_translation_parameters
5959

6060
**type**: ``array`` **default**: ``[]``
6161

62-
Translated `label`_ can contain
63-
:ref:`placeholders <component-translation-placeholders>`.
64-
This option allows you to pass an array of parameters in order to replace
65-
placeholders with actual values.
62+
.. versionadded:: 4.3
63+
64+
The ``label_translation_parameters`` option was introduced in Symfony 4.3.
65+
66+
The content of the `label`_ option is translated before displaying it, so it
67+
can contain :ref:`translation placeholders <component-translation-placeholders>`.
68+
This option defines the values used to replace those placeholders.
6669

6770
Given this translation message:
6871

6972
.. code-block:: yaml
7073
7174
# translations/messages.en.yml
72-
form.order.submit_to_company: Send an order to %company%
75+
form.order.submit_to_company: 'Send an order to %company%'
7376
74-
you can specify placeholder value:
77+
You can specify the placeholder values as follows:
7578

7679
.. code-block:: php
7780
7881
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
7982
// ...
8083
81-
$builder->add('send', ButtonType::class, array(
84+
$builder->add('send', ButtonType::class, [
8285
'label' => 'form.order.submit_to_company',
83-
'label_translation_parameters' => array(
86+
'label_translation_parameters' => [
8487
'%company%' => 'ACME Inc.',
85-
),
86-
));
87-
88-
Note that ``label_translation_parameters`` of buttons are merged with those of its
89-
parent. In other words the parent's translation parameters are available for
90-
children's buttons but can be overriden:
91-
92-
.. code-block:: php
93-
94-
// App/Controller/OrderController.php
95-
use App\Form\OrderType;
96-
// ...
97-
98-
$form = $this->createForm(OrderType::class, $order, array(
99-
// available to all children, grandchildren and so on.
100-
'label_translation_parameters' => array(
101-
'%company%' => 'ACME',
102-
),
103-
));
104-
105-
.. code-block:: php
106-
107-
// App/Form/OrderType.php
108-
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
109-
// ...
110-
111-
$builder->add('send', ButtonType::class, array(
112-
'label' => 'form.order.submit_to_company',
113-
// Value of parent's 'label_translation_parameters' will be merged with
114-
// this field's empty 'label_translation_parameters'.
115-
// array('%company%' => 'ACME') will be used to translate this label.
116-
));
117-
118-
.. code-block:: php
119-
120-
// App/Form/OrderType.php
121-
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
122-
// ...
88+
],
89+
]);
12390
124-
$builder->add('send', ButtonType::class, array(
125-
'label' => 'form.order.submit_to_company',
126-
'label_translation_parameters' => array(
127-
'%company%' => 'American Company Making Everything',
128-
),
129-
// Value of parent's 'label_translation_parameters' will be merged with
130-
// this button's 'label_translation_parameters'.
131-
// array('%company%' => 'American Company Making Everything')
132-
// will be used to translate this label.
133-
));
91+
The ``label_translation_parameters`` option of buttons is merged with the same
92+
option of its parents, so buttons can reuse and/or override any of the parent
93+
placeholders.
13494

13595
.. include:: /reference/forms/types/options/attr_translation_parameters.rst.inc

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

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ attr_translation_parameters
33

44
**type**: ``array`` **default**: ``[]``
55

6-
Some translated `attr`_ (``title`` and ``placeholder``) can
7-
contain :ref:`placeholders <component-translation-placeholders>`.
8-
This option allows you to pass an array of parameters in order to replace
9-
placeholders with actual values.
6+
.. versionadded:: 4.3
7+
8+
The ``attr_translation_parameters`` option was introduced in Symfony 4.3.
9+
10+
The content of the ``title`` and ``placeholder`` values defined in the `attr`_
11+
option is translated before displaying it, so it can contain
12+
:ref:`translation placeholders <component-translation-placeholders>`. This
13+
option defines the values used to replace those placeholders.
1014

1115
Given this translation message:
1216

1317
.. code-block:: yaml
1418

1519
# translations/messages.en.yml
16-
form.order.id.placeholder: Enter unique identifier of the order to %company%
17-
form.order.id.title: This will be the reference in communications with %company%
20+
form.order.id.placeholder: 'Enter unique identifier of the order to %company%'
21+
form.order.id.title: 'This will be the reference in communications with %company%'
1822

19-
you can specify placeholder value:
23+
You can specify the placeholder values as follows:
2024

2125
.. code-block:: php
2226

@@ -30,53 +34,6 @@ you can specify placeholder value:
3034
]
3135
));
3236

33-
Note that ``attr_translation_parameters`` of children fields are merged with those
34-
of its parent. In other words the parent's translation parameters are available
35-
for children but can be overriden:
36-
37-
.. code-block:: php
38-
39-
// App/Controller/OrderController.php
40-
use App\Form\OrderType;
41-
// ...
42-
43-
$form = $this->createForm(OrderType::class, $order, array(
44-
// available to all children, grandchildren and so on.
45-
'attr_translation_parameters' => array(
46-
'%company%' => 'ACME',
47-
),
48-
));
49-
50-
.. code-block:: php
51-
52-
// App/Form/OrderType.php
53-
// ...
54-
55-
$builder->add('id', null, array(
56-
'attr' => array(
57-
'placeholder' => 'form.order.id.placeholder',
58-
'title' => 'form.order.id.title',
59-
),
60-
// Value of parent's 'attr_translation_parameters' will be merged with
61-
// this field's empty 'attr_translation_parameters'.
62-
// array('%company%' => 'ACME') will be used to translate 'placeholder' and 'title'.
63-
));
64-
65-
.. code-block:: php
66-
67-
// App/Form/OrderType.php
68-
// ...
69-
70-
$builder->add('id', null, array(
71-
'attr' => array(
72-
'placeholder' => 'form.order.id.placeholder',
73-
'title' => 'form.order.id.title',
74-
),
75-
'attr_translation_parameters' => array(
76-
'%company%' => 'American Company Making Everything',
77-
),
78-
// Value of parent's 'attr_translation_parameters' will be merged with
79-
// this field's 'attr_translation_parameters'.
80-
// array('%company%' => 'American Company Making Everything')
81-
// will be used to translate 'placeholder' and 'title'.
82-
));
37+
The ``attr_translation_parameters`` option of children fields is merged with the
38+
same option of their parents, so children can reuse and/or override any of the
39+
parent placeholders.

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

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ help_translation_parameters
33

44
**type**: ``array`` **default**: ``[]``
55

6-
Translated `help`_ can
7-
contain :ref:`placeholders <component-translation-placeholders>`.
8-
This option allows you to pass an array of parameters in order to replace
9-
placeholders with actual values.
6+
.. versionadded:: 4.3
7+
8+
The ``help_translation_parameters`` option was introduced in Symfony 4.3.
9+
10+
The content of the `help`_ option is translated before displaying it, so it
11+
can contain :ref:`translation placeholders <component-translation-placeholders>`.
12+
This option defines the values used to replace those placeholders.
1013

1114
Given this translation message:
1215

1316
.. code-block:: yaml
1417

1518
# translations/messages.en.yml
16-
form.order.id.help: This will be the reference in communications with %company%
19+
form.order.id.help: 'This will be the reference in communications with %company%'
1720

18-
you can specify placeholder value:
21+
You can specify the placeholder values as follows:
1922

2023
.. code-block:: php
2124

@@ -26,47 +29,6 @@ you can specify placeholder value:
2629
]
2730
));
2831

29-
Note that ``help_translation_parameters`` of children fields are merged with those
30-
of its parent. In other words the parent's translation parameters are available
31-
for children but can be overriden:
32-
33-
.. code-block:: php
34-
35-
// App/Controller/OrderController.php
36-
use App\Form\OrderType;
37-
// ...
38-
39-
$form = $this->createForm(OrderType::class, $order, array(
40-
// available to all children, grandchildren and so on.
41-
'help_translation_parameters' => array(
42-
'%company%' => 'ACME',
43-
),
44-
));
45-
46-
.. code-block:: php
47-
48-
// App/Form/OrderType.php
49-
// ...
50-
51-
$builder->add('id', null, array(
52-
'help' => 'form.order.id.help',
53-
// Value of parent's 'help_translation_parameters' will be merged with
54-
// this field's empty 'help_translation_parameters'.
55-
// array('%company%' => 'ACME') will be used to translate 'help'.
56-
));
57-
58-
.. code-block:: php
59-
60-
// App/Form/OrderType.php
61-
// ...
62-
63-
$builder->add('id', null, array(
64-
'help' => 'form.order.id.help',
65-
'help_translation_parameters' => array(
66-
'%company%' => 'American Company Making Everything',
67-
),
68-
// Value of parent's 'help_translation_parameters' will be merged with
69-
// this field's 'help_translation_parameters'.
70-
// array('%company%' => 'American Company Making Everything')
71-
// will be used to translate 'help'.
72-
));
32+
The ``help_translation_parameters`` option of children fields is merged with the
33+
same option of their parents, so children can reuse and/or override any of the
34+
parent placeholders.

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

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ label_translation_parameters
33

44
**type**: ``array`` **default**: ``[]``
55

6-
Translated `label`_, can
7-
contain :ref:`placeholders <component-translation-placeholders>`.
8-
This option allows you to pass an array of parameters in order to replace
9-
placeholders with actual values.
6+
.. versionadded:: 4.3
7+
8+
The ``label_translation_parameters`` option was introduced in Symfony 4.3.
9+
10+
The content of the `label`_ option is translated before displaying it, so it
11+
can contain :ref:`translation placeholders <component-translation-placeholders>`.
12+
This option defines the values used to replace those placeholders.
1013

1114
Given this translation message:
1215

1316
.. code-block:: yaml
1417

1518
# translations/messages.en.yml
16-
form.order.id: Identifier of the order to %company%
19+
form.order.id: 'Identifier of the order to %company%'
1720

18-
you can specify placeholder value:
21+
You can specify the placeholder values as follows:
1922

2023
.. code-block:: php
2124

@@ -26,47 +29,6 @@ you can specify placeholder value:
2629
]
2730
));
2831

29-
Note that ``label_translation_parameters`` of children fields are merged with those
30-
of its parent. In other words the parent's translation parameters are available
31-
for children but can be overriden:
32-
33-
.. code-block:: php
34-
35-
// App/Controller/OrderController.php
36-
use App\Form\OrderType;
37-
// ...
38-
39-
$form = $this->createForm(OrderType::class, $order, array(
40-
// available to all children, grandchildren and so on.
41-
'label_translation_parameters' => array(
42-
'%company%' => 'ACME',
43-
),
44-
));
45-
46-
.. code-block:: php
47-
48-
// App/Form/OrderType.php
49-
// ...
50-
51-
$builder->add('id', null, array(
52-
'label' => 'form.order.id',
53-
// Value of parent's 'label_translation_parameters' will be merged with
54-
// this field's empty 'label_translation_parameters'.
55-
// array('%company%' => 'ACME') will be used to translate this label.
56-
));
57-
58-
.. code-block:: php
59-
60-
// App/Form/OrderType.php
61-
// ...
62-
63-
$builder->add('id', null, array(
64-
'label' => 'form.order.id',
65-
'label_translation_parameters' => array(
66-
'%company%' => 'American Company Making Everything',
67-
),
68-
// Value of parent's 'label_translation_parameters' will be merged with
69-
// this field's 'label_translation_parameters'.
70-
// array('%company%' => 'American Company Making Everything')
71-
// will be used to translate this label.
72-
));
32+
The ``label_translation_parameters`` option of children fields is merged with
33+
the same option of their parents, so children can reuse and/or override any of
34+
the parent placeholders.

0 commit comments

Comments
 (0)