Problem/Motivation

Drupal converts a radios element to multiple radio inside a fieldset.
The title is extended with the required property and passed into the fieldset label.

The fieldset then however ignores the required property.
See web/core/modules/system/templates/fieldset.html.twig

Thus the asterisk indicating required is missing.

Proposed resolution

Support required indication through the usual markup in fieldset labels.
This will fix all composite form elements (Radios, Checkboxes).

The usual markup is:
See web/themes/contrib/bs_base/themes/bs_bootstrap/templates/form/form-element-label.html.twig

    <label{{ attributes.addClass(classes) }}>{{ title }}{% if required %}<span class="form-required-mark"></span>{% endif %}</label>

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miro_dietiker created an issue. See original summary.

pivica’s picture

Actually logic for required fieldset existed, but it was not updated after https://cgit.drupalcode.org/bs_base/commit/?id=e9785a3 which added new span.form-required-mark element because previous require::after pseudo element were conflicting with Bootstrap custom form elements.

I've added span.form-required-mark to fieldset and details twig templates. Also added detection when form_group inserts required-fields CSS class in attributes - now we switch required flag to true.

Created example form and tested it against seven, looks good now:

Seven screenshot:

BS Bootstrap screenshot:

pivica’s picture

Status: Active » Needs review

  • pivica committed 76826d4 on 8.x-1.x authored by miro_dietiker
    Issue #3015068 by pivica, miro_dietiker: Required radios / fieldsets...
pivica’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.