Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[Form] New translation_parameters option#10065
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 7 commits intosymfony:masterfromwebnet-fr:form_translation_parametersMar 6, 2019
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
7 commits Select commitHold shift + click to select a range
c57d30a new translation_parameters form option
webnet-fr32e79e1 correct link error
webnet-fra655106 confirm with 28635
71fc7ce typo in form_translation_parameters docs
d7e7b0b correct attr link in entity type doc
70f36ad correct bug
20c6f5a correct arrays short syntax
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
82 changes: 82 additions & 0 deletionsreference/forms/types/button.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletionsreference/forms/types/choice.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletionsreference/forms/types/entity.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletionsreference/forms/types/form.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletionsreference/forms/types/options/attr_translation_parameters.rst.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| attr_translation_parameters | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| **type**: ``array`` **default**: ``[]`` | ||
| Some translated `attr`_ (``title`` and ``placeholder``) can | ||
| contain :ref:`placeholders <component-translation-placeholders>`. | ||
| This option allows you to pass an array of parameters in order to replace | ||
| placeholders with actual values. | ||
| Given this translation message: | ||
| .. code-block:: yaml | ||
| # translations/messages.en.yml | ||
| form.order.id.placeholder: Enter unique identifier of the order to %company% | ||
| form.order.id.title: This will be the reference in communications with %company% | ||
| you can specify placeholder value: | ||
| .. code-block:: php | ||
| $builder->add('id', null, array( | ||
| 'attr' => array( | ||
| 'placeholder' => 'form.order.id.placeholder', | ||
| 'title' => 'form.order.id.title', | ||
| ), | ||
| 'attr_translation_parameters' => [ | ||
| '%company%' => 'ACME Inc.' | ||
| ] | ||
| )); | ||
| Note that ``attr_translation_parameters`` of children fields are merged with those | ||
| of its parent. In other words the parent's translation parameters are available | ||
| for children but can be overriden: | ||
| .. code-block:: php | ||
| // App/Controller/OrderController.php | ||
| use App\Form\OrderType; | ||
| // ... | ||
| $form = $this->createForm(OrderType::class, $order, array( | ||
| // available to all children, grandchildren and so on. | ||
| 'attr_translation_parameters' => array( | ||
| '%company%' => 'ACME', | ||
| ), | ||
| )); | ||
| .. code-block:: php | ||
| // App/Form/OrderType.php | ||
| // ... | ||
| $builder->add('id', null, array( | ||
| 'attr' => array( | ||
| 'placeholder' => 'form.order.id.placeholder', | ||
| 'title' => 'form.order.id.title', | ||
| ), | ||
| // Value of parent's 'attr_translation_parameters' will be merged with | ||
| // this field's empty 'attr_translation_parameters'. | ||
| // array('%company%' => 'ACME') will be used to translate 'placeholder' and 'title'. | ||
| )); | ||
| .. code-block:: php | ||
| // App/Form/OrderType.php | ||
| // ... | ||
| $builder->add('id', null, array( | ||
| 'attr' => array( | ||
| 'placeholder' => 'form.order.id.placeholder', | ||
| 'title' => 'form.order.id.title', | ||
| ), | ||
| 'attr_translation_parameters' => array( | ||
| '%company%' => 'American Company Making Everything', | ||
| ), | ||
| // Value of parent's 'attr_translation_parameters' will be merged with | ||
| // this field's 'attr_translation_parameters'. | ||
| // array('%company%' => 'American Company Making Everything') | ||
| // will be used to translate 'placeholder' and 'title'. | ||
| )); |
2 changes: 1 addition & 1 deletionreference/forms/types/options/choice_type_translation_domain.rst.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletionsreference/forms/types/options/help_translation_parameters.rst.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| help_translation_parameters | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| **type**: ``array`` **default**: ``[]`` | ||
| Translated `help`_ can | ||
| contain :ref:`placeholders <component-translation-placeholders>`. | ||
| This option allows you to pass an array of parameters in order to replace | ||
| placeholders with actual values. | ||
| Given this translation message: | ||
| .. code-block:: yaml | ||
| # translations/messages.en.yml | ||
| form.order.id.help: This will be the reference in communications with %company% | ||
| you can specify placeholder value: | ||
| .. code-block:: php | ||
| $builder->add('id', null, array( | ||
| 'help' => 'form.order.id.help', | ||
| 'help_translation_parameters' => [ | ||
| '%company%' => 'ACME Inc.' | ||
| ] | ||
| )); | ||
| Note that ``help_translation_parameters`` of children fields are merged with those | ||
| of its parent. In other words the parent's translation parameters are available | ||
| for children but can be overriden: | ||
| .. code-block:: php | ||
| // App/Controller/OrderController.php | ||
| use App\Form\OrderType; | ||
| // ... | ||
| $form = $this->createForm(OrderType::class, $order, array( | ||
| // available to all children, grandchildren and so on. | ||
| 'help_translation_parameters' => array( | ||
| '%company%' => 'ACME', | ||
| ), | ||
| )); | ||
| .. code-block:: php | ||
| // App/Form/OrderType.php | ||
| // ... | ||
| $builder->add('id', null, array( | ||
| 'help' => 'form.order.id.help', | ||
| // Value of parent's 'help_translation_parameters' will be merged with | ||
| // this field's empty 'help_translation_parameters'. | ||
| // array('%company%' => 'ACME') will be used to translate 'help'. | ||
| )); | ||
| .. code-block:: php | ||
| // App/Form/OrderType.php | ||
| // ... | ||
| $builder->add('id', null, array( | ||
| 'help' => 'form.order.id.help', | ||
| 'help_translation_parameters' => array( | ||
| '%company%' => 'American Company Making Everything', | ||
| ), | ||
| // Value of parent's 'help_translation_parameters' will be merged with | ||
| // this field's 'help_translation_parameters'. | ||
| // array('%company%' => 'American Company Making Everything') | ||
| // will be used to translate 'help'. | ||
| )); |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.