Problem/Motivation
There's an incorrect error message for the form validation if a link in the checkbox label
Steps to reproduce
When you have some checkbox on the form (e.g. registration form) and this checkbox is required, then you submit the form without checking the box you will see the error message, and this message is incorrect because of renderer with HTML as a text
Proposed resolution
Use Markup for the text if this text contains some link
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | inline-form-errors-links.patch | 1.09 KB | rolki |
| Снимок экрана 2021-03-17 в 11.49.01.png | 172.75 KB | rolki |
Issue fork drupal-3204000
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rolki commentedHere's the patch to resolve this issue.
The solution can be better I think, but for now, it is a hotfix
Comment #3
rolki commentedComment #4
Madhu kumar commentedpatch #2 is applied cleanly and working well.
Comment #8
krzysztof domańskiComment #9
marcin maruszewski commentedHi! First of all, thanks for creating this issue. I had a similar problem. I also had a checkbox with a link to the Privacy Policy page, and the inline_form_error module was messing this up.
First I thought that a good idea is to wrap form element #title using FormattableMarkup. But then I realized that in the end there is a
<a>tag with anchor to form element (for example<a href="#edit-privacy-poilcy">), and inside it there is another<a>with link to my Privacy Policy page. This breaks HTML5 standards and a11y too.Using Markup::create in the inline_form_error module will create the same issue.
So my idea is to remove all HTML markup from label using the Drupal\Component\Utility\Xss::filter method.
When I was writing this comment I got a message from @krzysztof-domanski that there is a similar issue over here - https://www.drupal.org/project/drupal/issues/3010092. Maybe we could solve this issue using the experience of all of the contributors?
Comment #11
smustgrave commentedSo sounds like this is a duplicate of https://www.drupal.org/project/drupal/issues/3010092 should this be closed then?