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

Commitc57d30a

Browse files
webnet-frVladyslav Riabchenko
authored and
Vladyslav Riabchenko
committed
new translation_parameters form option
1 parent927dee1 commitc57d30a

14 files changed

+343
-2
lines changed

‎reference/forms/types/button.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A simple, non-responsive button.
1313
| options| - `disabled`_|
1414
|| - `label`_|
1515
|| - `translation_domain`_|
16+
|| - `translation_parameters`_|
1617
+----------------------+----------------------------------------------------------------------+
1718
| Parent type| none|
1819
+----------------------+----------------------------------------------------------------------+
@@ -51,3 +52,5 @@ as a key. This can be useful when you need to set a custom class for the button:
5152
..include::/reference/forms/types/options/button_label.rst.inc
5253

5354
..include::/reference/forms/types/options/button_translation_domain.rst.inc
55+
56+
..include::/reference/forms/types/options/button_translation_parameters.rst.inc

‎reference/forms/types/choice.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
4545
|| - `mapped`_|
4646
|| - `required`_|
4747
|| - `translation_domain`_|
48+
|| - `translation_parameters`_|
4849
+-------------+------------------------------------------------------------------------------+
4950
| Parent type|:doc:`FormType</reference/forms/types/form>`|
5051
+-------------+------------------------------------------------------------------------------+
@@ -297,6 +298,8 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
297298

298299
..include::/reference/forms/types/options/choice_type_translation_domain.rst.inc
299300

301+
..include::/reference/forms/types/options/choice_type_translation_parameters.rst.inc
302+
300303
Field Variables
301304
---------------
302305

‎reference/forms/types/entity.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ objects from the database.
3232
|| - `placeholder`_|
3333
|| - `preferred_choices`_|
3434
|| - `translation_domain`_|
35+
|| - `translation_parameters`_|
3536
|| - `trim`_|
3637
|||
3738
|| from the:doc:`FormType</reference/forms/types/form>`:|
@@ -307,6 +308,8 @@ when rendering the field:
307308
308309
..include::/reference/forms/types/options/choice_type_translation_domain.rst.inc
309310

311+
..include::/reference/forms/types/options/entity_type_translation_parameters.rst.inc
312+
310313
..include::/reference/forms/types/options/choice_type_trim.rst.inc
311314

312315
These options inherit from the:doc:`form</reference/forms/types/form>`

‎reference/forms/types/form.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ on all types for which ``FormType`` is the parent.
4242
|| - `disabled`_|
4343
|| - `label`_|
4444
|| - `translation_domain`_|
45+
|| - `translation_parameters`_|
4546
+-----------+--------------------------------------------------------------------+
4647
| Parent| none|
4748
+-----------+--------------------------------------------------------------------+
@@ -167,3 +168,5 @@ of the form type tree (i.e. it cannot be used as a form type on its own).
167168
..include::/reference/forms/types/options/label.rst.inc
168169

169170
..include::/reference/forms/types/options/translation_domain.rst.inc
171+
172+
..include::/reference/forms/types/options/translation_parameters.rst.inc
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
translation_parameters
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``array()``
5+
6+
Translated `label`_ can contain
7+
: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.
10+
11+
Given this translation message:
12+
13+
.. code-block:: yaml
14+
15+
# translations/messages.en.yml
16+
form.order_list.submit_to_company: Send an order to %company%
17+
18+
you can specify placeholder value:
19+
20+
.. code-block:: php
21+
22+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
23+
// ...
24+
25+
$builder->add('send', ButtonType::class, array(
26+
'label' => 'form.order_list.submit_to_company',
27+
'translation_parameters' => array(
28+
'%company%' => 'ACME Inc.'
29+
)
30+
));
31+
32+
Note that `translation_parameters` of buttons are merged with those of parent.
33+
In other words the parent's parameters are available for buttons but can be
34+
overriden:
35+
36+
.. code-block:: php
37+
38+
// App\Controller\OrderListController
39+
40+
$form = $this->createForm(OrderListType::class, null, array(
41+
'translation_parameters' => array(
42+
'%company%' => 'ACME Inc.'
43+
)
44+
));
45+
46+
.. code-block:: php
47+
48+
// App\Form\OrderListType
49+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
50+
// ...
51+
52+
$builder->add('send', ButtonType::class, array(
53+
'label' => 'form.order_list.submit_to_company',
54+
));

‎reference/forms/types/options/choice_type_translation_domain.rst.inc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ translation_domain
55

66
In case`choice_translation_domain`_ isset to``true``or``null``, this
77
configures the exact translation domain that will be used for any labelsor
8-
options that are rendered for this field
8+
options that are rendered for this field.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
translation_parameters
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``array()``
5+
6+
Translated `label`_, `help`_ and some attr_ (``title``, ``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.
10+
11+
Given this translation message:
12+
13+
.. code-block:: yaml
14+
15+
# translations/messages.en.yml
16+
form.order_list.notify: Notify %company%
17+
18+
you can specify placeholder value:
19+
20+
.. code-block:: php
21+
22+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
23+
// ...
24+
25+
$builder->add('send', ChoiceType::class, array(
26+
// ...
27+
'label' => 'form.order_list.notify',
28+
'translation_parameters' => array(
29+
'%company%' => 'ACME Inc.'
30+
)
31+
));
32+
33+
Note that `translation_parameters` of choice fields are merged with those of parent.
34+
In other words the parent's parameters are available for choice fields
35+
but can be overriden:
36+
37+
.. code-block:: php
38+
39+
// App\Controller\OrderListController
40+
41+
$form = $this->createForm(OrderListType::class, null, array(
42+
'translation_parameters' => array(
43+
'%company%' => 'ACME Inc.'
44+
)
45+
));
46+
47+
.. code-block:: php
48+
49+
// App\Form\OrderListType
50+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
51+
// ...
52+
53+
$builder->add('send', ChoiceType::class, array(
54+
// ...
55+
'label' => 'form.order_list.notify',
56+
));
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
translation_parameters
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``array()``
5+
6+
Translated `label`_, `help`_ and some attr_ (``title``, ``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.
10+
11+
Given this translation message:
12+
13+
.. code-block:: yaml
14+
15+
# translations/messages.en.yml
16+
form.order_list.notify: Notify %company%
17+
18+
you can specify placeholder value:
19+
20+
.. code-block:: php
21+
22+
use Symfony\Component\Form\Extension\Core\Type\EntityType;
23+
// ...
24+
25+
$builder->add('send', EntityType::class, array(
26+
// ...
27+
'label' => 'form.order_list.notify',
28+
'translation_parameters' => array(
29+
'%company%' => 'ACME Inc.'
30+
)
31+
));
32+
33+
Note that `translation_parameters` of entity fields are merged with those of parent.
34+
In other words the parent's parameters are available for entity fields
35+
but can be overriden:
36+
37+
.. code-block:: php
38+
39+
// App\Controller\OrderListController
40+
41+
$form = $this->createForm(OrderListType::class, null, array(
42+
'translation_parameters' => array(
43+
'%company%' => 'ACME Inc.'
44+
)
45+
));
46+
47+
.. code-block:: php
48+
49+
// App\Form\OrderListType
50+
use Symfony\Component\Form\Extension\Core\Type\EntityType;
51+
// ...
52+
53+
$builder->add('send', EntityType::class, array(
54+
// ...
55+
'label' => 'form.order_list.notify',
56+
));
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
translation_parameters
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``array()``
5+
6+
Translated `label`_ can contain
7+
: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.
10+
11+
Given this translation message:
12+
13+
.. code-block:: yaml
14+
15+
# translations/messages.en.yml
16+
form.order_list.submit_to_company: Send an order to %company%
17+
18+
you can specify placeholder value:
19+
20+
.. code-block:: php
21+
22+
use Symfony\Component\Form\Extension\Core\Type\ResetType;
23+
// ...
24+
25+
$builder->add('send', ResetType::class, array(
26+
'label' => 'form.order_list.submit_to_company',
27+
'translation_parameters' => array(
28+
'%company%' => 'ACME Inc.'
29+
)
30+
));
31+
32+
Note that `translation_parameters` of reset fields are merged with those of
33+
parent form. In other words the parent's parameters are available for reset
34+
fields but can be overriden:
35+
36+
.. code-block:: php
37+
38+
// App\Controller\OrderListController
39+
40+
$form = $this->createForm(OrderListType::class, null, array(
41+
'translation_parameters' => array(
42+
'%company%' => 'ACME Inc.'
43+
)
44+
));
45+
46+
.. code-block:: php
47+
48+
// App\Form\OrderListType
49+
use Symfony\Component\Form\Extension\Core\Type\ResetType;
50+
// ...
51+
52+
$builder->add('send', ResetType::class, array(
53+
'label' => 'form.order_list.submit_to_company',
54+
));
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
translation_parameters
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``array()``
5+
6+
Translated `label`_ can contain
7+
: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.
10+
11+
Given this translation message:
12+
13+
.. code-block:: yaml
14+
15+
# translations/messages.en.yml
16+
form.order_list.submit_to_company: Send an order to %company%
17+
18+
you can specify placeholder value:
19+
20+
.. code-block:: php
21+
22+
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
23+
// ...
24+
25+
$builder->add('send', SubmitType::class, array(
26+
'label' => 'form.order_list.submit_to_company',
27+
'translation_parameters' => array(
28+
'%company%' => 'ACME Inc.'
29+
)
30+
));
31+
32+
Note that `translation_parameters` of submit fields are merged with those of
33+
parent. In other words the parent's parameters are available for submit fields
34+
but can be overriden:
35+
36+
.. code-block:: php
37+
38+
// App\Controller\OrderListController
39+
40+
$form = $this->createForm(OrderListType::class, null, array(
41+
'translation_parameters' => array(
42+
'%company%' => 'ACME Inc.'
43+
)
44+
));
45+
46+
.. code-block:: php
47+
48+
// App\Form\OrderListType
49+
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
50+
// ...
51+
52+
$builder->add('send', SubmitType::class, array(
53+
'label' => 'form.order_list.submit_to_company',
54+
));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp