8000 [Form] PercentType support for hiding the percent symbol · Issue #28796 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] PercentType support for hiding the percent symbol #28796

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
d42ohpaz opened this issue Oct 9, 2018 · 0 comments
Closed

[Form] PercentType support for hiding the percent symbol #28796

d42ohpaz opened this issue Oct 9, 2018 · 0 comments

Comments

@d42ohpaz
Copy link
d42ohpaz commented Oct 9, 2018

Description
Similar to the MoneyType currency option, it would be beneficial to add an option to the PercentType that would allow disabling the percent symbol (%). The default should be true to keep backward compatibility, but accept false to disable it being rendered in Twig.

Example

$this->createFormBuilder($entity)
    ->add('percent', PercentType::class, [
        'symbol' => false,
    ]);

...

{{ form_widget(form.percent) }} 

The above would render:

<input type="text" id="my_form_percent" name="percent" required="required">
@fabpot fabpot closed this as completed Mar 5, 2019
fabpot added a commit that referenced this issue Mar 5, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0