-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Twig/Forms] not possible to set title for button without text #34330
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
Comments
Which form theme do you use? |
I was using bootstrap_4_layout |
I've had a go at reproducing this, but I can't seem to do so. By setting label to false and setting attr['title'] as you have, the title comes through fine for me. This is on 4.3.8, mind you, the latest stable version. Bootstrap 4 form styling all configured. My reproduction attempt is at https://github.com/stephen-lewis/symfony_bug_34330_reproducer, and as you can see by the screenshot below, the title attribute is there (a tooltip also displays, but I couldn't capture that!). Perhaps there is something else going wrong... I'd start by upgrading to 4.3.x. Then, if the issue persists, can you give some more detail so we can reproduce it? |
I'm sorry, my fault - bad description and title it's not possible to translate title for button without text |
No worries, your workaround makes more sense now! I've reproduced it in latest; can confirm issue: |
button_widget explicitly sets translation_domain to false if label==false. translation_domain is then checked for false to avoid breaking the translator if it tries to translate a non-string. I've created a pull request that changes this logic to check both the label and the translation_domain for false prior to translating, and then removed the explicit setting of translation_domain to false. I've tested it and there does't seem to be any side effects. EDIT: grammar |
@poolerMF Creating button without text should not be possible. You SHOULD never ever create button without text and only with icon. Button without text inside is not accessible for screen readers, which means that blind people won't be able to use that button (title attr is not solution here). It does not mean that you cannot hide text button. You can if your design requires this. But in HTML itself (in this case, in HTML generated by Symfony Form component & Twig) text should be placed inside the button but YOU should wrap that text around some wrapper with visually hidden class which hides contents from the screen but keeps it available for blind people. Proper .visually-hidden implementation example: https://a11yproject.com/posts/how-to-hide-content/ To fix your problem you can:
|
@TomaszGasior the button may have an icon where text is not needed ... but title is required |
…ed even if its label = null or false (stephen-lewis) This PR was squashed before being merged into the 3.4 branch (closes #35193). Discussion ---------- [TwigBridge] button_widget now has its title attr translated even if its label = null or false | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34330 | License | MIT | Doc PR | TODO Duplicate of #34436 but changed to bugfix and applied to 3.4. Buttons with null or false 'label' options will now have their 'title' attribute translated against the current translation domain. Commits ------- 2a5d9cb [TwigBridge] button_widget now has its title attr translated even if its label = null or false
Symfony version(s) affected: every ?
Description
How to reproduce
My Solution
override block button_widget
override block button_attributes
The text was updated successfully, but these errors were encountered: