Please sign in to comment.
feature #30433 [Form] Allow to disable and customize PercentType symb…
…ol (Ken Stanley, OskarStark) This PR was merged into the 4.3-dev branch. Discussion ---------- [Form] Allow to disable and customize PercentType symbol | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #28796 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#11078 <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> ## `PercentType` `symbol` option As of this writing, Symfony will forcibly append a percentage sign (`%`) to all input fields that are of the PercentType form type. This PR will introduce a boolean flag called `symbol` that, when `false`, will not display the percentage sign. Each of the default layouts that define percent_widget will respect this option. You could also use a customised string as value for `symbol` option. By default, this new option will be set to `true` so that it maintains backward compatibility. The unit tests have been updated where appropriate, and a new unit test has been added (as appropriate). Commits ------- 53c5f41 [Form] Allow to disable and customize PercentType symbol 9aeaea0 Add ‘symbol’ option to PercentType
- Loading branch information...
Showing with 152 additions and 18 deletions.
- +9 −5 src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig
- +7 −3 src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig
- +1 −1 src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
- +12 −6 src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig
- +36 −0 src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
- +41 −2 src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php
- +2 −1 src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php
- +1 −0 src/Symfony/Component/Form/CHANGELOG.md
- +12 −0 src/Symfony/Component/Form/Extension/Core/Type/PercentType.php
- +31 −0 src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
|@@ -1 +1,2 @@|
|<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']) ?> %|
|<?php $symbol = false !== $symbol ? ($symbol ? ' '.$symbol : ' %') : '' ?>|
|<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']).$symbol ?>|