Skip to content

[Form] Suggestion: Add CSS hyphens: none when expanding the {{ value }} placeholder in error messages #60319

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

Open
ThomasLandauer opened this issue May 1, 2025 · 1 comment
Labels

Comments

@ThomasLandauer
Copy link
Contributor

Description

While playing around with long email addresses, I noticed that they sometimes get hyphenized in form's error messages: With

#[Assert\Email(message: '{{ value }} is not a valid email address')]

... when entering foooooooooooobar@example.com, then the error message might come out as:

foooooooooooo-
bar@example.com
is not a valid email address

So I'm suggesting to wrap {{ value }} into a <span style="hyphens:none">.

At first, I thought about adding an additional flag (like e.g. {{ value|hyphensNone }}), but now I'm thinking that any modification of the user's input might lead to confusion, so it's probably better to always suppress hyphenation.

Open question: How to deal with non-HTML output?

Example

No response

@carsonbot carsonbot added the Form label May 1, 2025
@smnandre
Copy link
Member

smnandre commented May 3, 2025

Hyphenation is handled by the browser, but validation messages can appear in many contexts (XML, ANSI, JSON, etc.), where any added <span> would cause issues.

Additionally, hyphenation depends on many factors—browser defaults, CSS context, HTML lang attribute—and may have been intentionally configured by developers for good reasons.

If you absolutely want to prevent it, the simplest solution would be to add a custom block in your form theme, or just a few lines of CSS, depending on your preferred framework or method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants