Skip to content

Adding label_html for asterisk #15237

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

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

ThomasLandauer
Copy link
Contributor

@ThomasLandauer ThomasLandauer commented Apr 13, 2021

Closes #14915

I hope I got the link right - please double-check :-)

@javiereguiluz
Copy link
Member

I don't fully understand the proposed solution. Do we tell readers that they add the asterisk manually with some HTML tags? If that's the proposed solution, I'd prefer to wait for a better alternative.

Maybe the solution is to no longer display errors inside <label>, which doesn't seem like a common practice (although it was originally well-intended to improve accessibility). Bootstrap 5 for example doesn't use that to add errors to forms: https://getbootstrap.com/docs/5.0/forms/validation/#server-side

@ThomasLandauer
Copy link
Contributor Author

Do we tell readers that they add the asterisk manually with some HTML tags?

Yes ;-)

What Bootstrap shows on its own page is not so relevant in this case, since they didn't have the error inside the label in v4 either: https://getbootstrap.com/docs/4.6/components/forms/#validation

What's more important is that in the Bootstrap 5 theme, the error is now placed outside the label:
https://github.com/symfony/symfony-docs/pull/15158/files#diff-6a410d85cbf857ef1ce4fd7e3f5c429e3497cd5d90353bca8fb55125433c9045R91

BUT: Seeing that the Bootstrap 3 theme is still around https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig, v4 will probably stay alive for some time too.

Better solution? Well, any code change would be a BC break; that's certainly not worth it. So I think it's down to: Either give people a hint about this, or just don't ;-)

Clarification: The HTML is only needed if you want the asterisk to be red - otherwise you obviously can just type it into the "regular" label.

@javiereguiluz javiereguiluz changed the base branch from 5.2 to 4.4 May 21, 2021 15:06
@javiereguiluz
Copy link
Member

Thank you Thomas.

@javiereguiluz javiereguiluz merged commit 5818046 into symfony:4.4 May 21, 2021
@ThomasLandauer ThomasLandauer deleted the patch-18 branch May 21, 2021 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants