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

Issue fork drupal-3204000

Command icon 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

rolki created an issue. See original summary.

rolki’s picture

StatusFileSize
new1.09 KB

Here's the patch to resolve this issue.
The solution can be better I think, but for now, it is a hotfix

rolki’s picture

Status: Active » Needs review
Madhu kumar’s picture

patch #2 is applied cleanly and working well.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Marcin Maruszewski made their first commit to this issue’s fork.

krzysztof domański’s picture

marcin maruszewski’s picture

Hi! 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?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

So sounds like this is a duplicate of https://www.drupal.org/project/drupal/issues/3010092 should this be closed then?

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.