-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fix the money form type render with Bootstrap3 #19426
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
Conversation
@@ -21,8 +21,8 @@ | |||
|
|||
{% block money_widget -%} | |||
<div class="input-group"> | |||
{% set prepend = '{{' == money_pattern[0:2] %} | |||
{% if not prepend %} | |||
{% set prepend = '{{' != money_pattern[0:2] %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the readability of the starts with
Twig operator. If you agree, you could change this code as follows:
{% block money_widget -%}
<div class="input-group">
{% set append = money_pattern starts with '{{' %}
{% if not append %}
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
{% endif %}
{{- block('form_widget_simple') -}}
{% if append %}
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
{% endif %}
</div>
{%- endblock money_widget %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love too, i didn't think about it.
@javiereguiluz: I've searched long time ago the not starts with
feature but seems impossible right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it is not. It needs to be not money_pattern starts with '...'
There is a confusion between the variable naming, and the result expected. When prepend variable is false, the currency symbol must be add after the widget. When the money_patternstarts with {{, prepend variable must be false.
👍 Status: reviewed |
Thank you @Th3Mouk. |
…Mouk) This PR was merged into the 2.7 branch. Discussion ---------- [Form] Fix the money form type render with Bootstrap3 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | Part fixing #19424 | License | MIT | Doc PR | none There is a confusion between the variable naming, and the result expected. When prepend variable is false, the currency symbol must be add after the widget. When the `money_pattern`starts with `{{`, `prepend` variable must be `false`. Commits ------- 637a441 Fix the money form type render with Bootstrap3
Hum looking at the issue and the time of submission, I may have merged this one to quickly? Is it OK or should we revert? |
@nicolas-grekas no it's OK, the other part of the problem "doesn't exist". The part of code that i was talking isn't called when |
There is a confusion between the variable naming, and the result expected.
When prepend variable is false, the currency symbol must be add after the widget.
When the
money_pattern
starts with{{
,prepend
variable must befalse
.