-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge][Form] Fix hidden currency element with Bootstrap 3 theme #25233
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
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.
👍 conflicts with #25167
[@type="text"] | ||
[@name="name"] | ||
[@class="my&class form-control"] | ||
[@value="1234.56"] |
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.
does this prevent regression also?
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.
What kind of regression do you mean?
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.
if a input-group-addon
is rendered again, this xpath would still match no?
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.
Indeed, the test still passes if any extra element is rendered, as long as the <input>
is at first nesting level. But this actually applies to most of these tests with XPath. This could (should?) probably be improved but in a separate PR IMO. WDYT?
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.
Yeah, but now we just test form_widget_simple
again; which is probably already covered in some other test. For this new test i'd expect it to cover the change; no rendering of input addons in case of currency=false.
Or at least not containing a currency symbol in general.
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.
Added more predicates.
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.
Nice!
{% if not append %} | ||
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span> | ||
{% endif %} | ||
{% set append_before = not (money_pattern starts with '{{') %} |
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.
what about a check like money_pattern is '{{ widget }}'
wouldnt that be more concise?
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.
Don't know, a starts with
or ends with
test would still be required in case the currency symbol must be appended.
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.
Right, lets call those variables append
+ prepend
?
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.
Done.
c1e8ca0
to
31f3a4f
Compare
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.
Nice catch. Perhaps, to close the gates, add 2 more tests in MoneyTypeTest
$this->assertSame('{{ widget }}', $view->vars['money_pattern']); // currency=false
$this->assertSame('... {{ widget }}', $view->vars['money_pattern']); // prepended currency
31f3a4f
to
c5af7fd
Compare
Tests added. |
Do we have the same issue with Bootstrap 4 support? |
It looks like when Bootstrap 4 theme was added, most of the content of the Bootstrap 3 theme was moved to a common file used by both so yes, I think Bootstrap 4 theme has the same issue. Merging this PR up to 3.4 would probably bring conflicts: the patch must be moved to the common file, which will also fix the issue for Bootstrap 4. Same applies with the tests as they use a common base class. |
Thank you @julienfalque. |
…rap 3 theme (julienfalque) This PR was merged into the 2.7 branch. Discussion ---------- [TwigBridge][Form] Fix hidden currency element with Bootstrap 3 theme | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - When using a `MoneyType` field, one can pass `currency=false` option to hide the currency symbol. This does not work well when using the Bootstrap 3 theme: the symbol is not displayed but HTML elements that are supposed to contain it are still rendered. Commits ------- c5af7fd Fix hidden currency element with Bootstrap 3 theme
When using a
MoneyType
field, one can passcurrency=false
option to hide the currency symbol. This does not work well when using the Bootstrap 3 theme: the symbol is not displayed but HTML elements that are supposed to contain it are still rendered.