Problem/Motivation

When using state required, the asterisk doesn't show.
State required no asterisk

Proposed resolution

- Modify state.js on required to add classes "js-form-required form-required" on label or legend.
State required with asterisk

Remaining tasks

- Review patch

CommentFileSizeAuthor
#81 2912092-11-2-10-81.patch8.25 KBshani maurya
#80 2912092-state-required-fix-v2-80.diff26.24 KBherved
#80 2912092-state-required-asterisk-80.diff10.27 KBherved
#76 2912092-76.patch9.45 KBdench0
#72 2912092-3342118.patch8.83 KBpcambra
#71 2912092.patch8.47 KBpcambra
#70 2912092-70.diff8.95 KBherved
#67 2912092-67-10-1-x.patch8.41 KBmdolnik
#67 2912092-67-9-5-x.patch10.79 KBmdolnik
#67 2912092-67-8-9-x.patch11.04 KBmdolnik
#65 interdiff_54-rerolled.txt655 bytesfathima.asmat
#65 state-required-asterisk-doesnt-show-2912092-54-rerolled.patch8.54 KBfathima.asmat
#62 2912092-62.patch5.66 KB_utsavsharma
#62 interdiff_d10.txt5.66 KB_utsavsharma
#58 interdiff-57-58.txt2.04 KBherved
#58 2912092-58.patch10.15 KBherved
#57 2912092-57.patch10.22 KBherved
#56 interdiff_55-56.txt3.93 KBnitin shrivastava
#56 2912092-56.patch10.69 KBnitin shrivastava
#55 state-required-asterisk-doesnt-show-2912092-54.patch9.23 KBmrdalesmith
#53 2022-09-22_date_fields_old2.png19.18 KBmdolnik
#52 2022-09-22_date_fields_newD9.png27.47 KBmdolnik
#52 2022-09-22_date_fields_old.png25.87 KBmdolnik
#52 2022-09-22_formatted_fields_new.png61.68 KBmdolnik
#52 2022-09-22_formatted_fields_old.png62.33 KBmdolnik
#52 2022-09-22_multivalue_fields_new.png17.9 KBmdolnik
#52 2022-09-22_multivalue_fields_old.png17.75 KBmdolnik
#52 interdiff_48-52.txt11.01 KBmdolnik
#52 2912092-52.patch10.64 KBmdolnik
#48 interdiff_44-48.txt2.46 KBcolin.eininger
#48 ie-fix-2912092-48.patch2.85 KBcolin.eininger
#44 2912092-44.patch2.87 KByogeshmpawar
#44 interdiff-2912092-42-44.txt1.53 KByogeshmpawar
#42 2912092-42.patch2.85 KByogeshmpawar
#37 2912092-37-state-required-asterisk-d8.patch2.96 KBsime
#34 2912092-34.patch2.97 KBkevinvb
#31 interdiff-29-31.txt624 bytesVidushi Mehta
#31 2912092-31.patch2.86 KBVidushi Mehta
#29 2912092-29.patch2.83 KBridhimaabrol24
#21 core-states-required-2912092-21.patch2.79 KBgugalamaciek
#19 core-states-required-2912092-19.patch2.77 KBrp7
#13 core-states-required-2912092-12.patch2.76 KBannetee
#12 core-states-required-2912092-6.patch2.76 KBannetee
#8 Logic.png61.05 KBmahalingam_cs
#8 Form.png31.48 KBmahalingam_cs
#6 states-required-2912092.patch3 KBvqgr
#2 states-required-2912092.patch1.41 KBvqgr
Screenshot_20172709_2.png14.08 KBvqgr
Screenshot_20172709_1.png13.27 KBvqgr

Issue fork drupal-2912092

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

vqgr created an issue. See original summary.

vqgr’s picture

StatusFileSize
new1.41 KB
vqgr’s picture

Issue tags: +need review
vqgr’s picture

Status: Active » Needs review
naiduharish’s picture

Status: Needs review » Needs work
Issue tags: -need review +need work

Hey @vqgr,

You need to make changes in states.es6.js as Drupal is now using ES6 for javascript development. Please refer https://www.drupal.org/node/2815083

vqgr’s picture

StatusFileSize
new3 KB

Hey @naiduharish,

Sorry I didn't know about the es6 part, thanks for your feedback.

Here is updated patch, following recommandations.

vqgr’s picture

Status: Needs work » Needs review
Issue tags: -need work +need review
mahalingam_cs’s picture

Status: Needs review » Needs work
StatusFileSize
new31.48 KB
new61.05 KB

Applied patch from #6. Patch applied without any error but the change is not working.When using state required, the asterisk is not displayed.
Screenshot attached.

vqgr’s picture

Hello @mahalingam_cs,

I need more informations to reproduce, did you clear your browser cache ?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

annetee’s picture

StatusFileSize
new2.76 KB

The patch in #6 wouldn't apply since the line numbers are off - the states.es6.js file must have been updated since that patch was created. I've updated the patch with the current code. Thanks @vqgr for the original code.

annetee’s picture

StatusFileSize
new2.76 KB

Just found a bug in the code that was preventing the required classes from being removed when an element should have gone from required to optional. I'm attaching an updated patch.

annetee’s picture

Status: Needs work » Needs review
volkswagenchick’s picture

Issue tags: +badcamp 2018

tagging for badcamp 2018

joshua.boltz’s picture

The patch seems to resolve the issue of showing/hiding the asterisk when a form field's #states change.
In my case, I have a form_alter that handles #states changes of Paragraph form field subform elements when another field value is changed.

$element['subform']['field_text']['#states'] = [
  'required' => [
    ':input[name="field_video[0][subform][field_variation]"]' => ['value' => 'curate'],
  ],
];

In this example, in the field_video field, which is a an entity reference revisions/paragraph field on the node, when the field_variation field within it changes to Curated, the field_text is set to required, and when the value is Topic, the field_text is set to not required.

This is working properly, due to this patch, but it turns out there is another issue where now the node form is not submitting and is giving this Javascript error:

An invalid form control with name='field_video[0][subform][field_text][0][target_id]' is not focusable.

I assume it's some incompatibility with paragraphs fields like in the way I'm trying to do it.

maximpodorov’s picture

Time to change the version to 8.7?

manuel garcia’s picture

rp7’s picture

StatusFileSize
new2.77 KB

Rerolled patch in #13 for D8.6.13

volkswagenchick’s picture

Issue tags: +drupalnorth2019

Tagging for DrupalNorth 2019

gugalamaciek’s picture

StatusFileSize
new2.79 KB

The last patch won't work for me. When debugged, the problem is with:

var child = e.target.querySelector('label, legend');

e.target is input (or any other form element), so finding label/legend inside it fails. For me this improvement works:

var child = e.target.parentNode.querySelector('label, legend');

Attaching patch.

gugalamaciek’s picture

This issue solves the problem partially. There is still problem with '#type' => 'datetime' items. See issue https://www.drupal.org/project/drupal/issues/2419131. It covers all - asterix works for every #type.

volkswagenchick’s picture

Issue tags: +dcco2019

Tagging for DrupalCamp Colorado 2019 (Sunday August 4)

gooddenis’s picture

Thank you! It works for me.

gooddenis’s picture

Status: Needs review » Needs work

We should remove HTML attribute 'required="required"' from the too.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

init90’s picture

Issue tags: +FAPI #states

Added relevant tag

ridhimaabrol24’s picture

Status: Needs work » Needs review
StatusFileSize
new2.83 KB

Reroll patch for 9.1 with #25 also implemented.

colin.eininger’s picture

Status: Needs review » Needs work

Using the bootstrap theme which adds a wrapper around the select element this code fails to add the mark on the label.

const child = e.target.parentNode.querySelector('label, legend');
const variable = child ? child.tagName.toLowerCase() : '';

I think it's more flexible to do it like this :

const $child = $(e.target).closest('.js-form-item').find('label, legend');
const variable = $child.length ? $child.first().prop('tagName').toLowerCase() : '';
Vidushi Mehta’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB
new624 bytes

Added a patch which covered the point by #30.

tanubansal’s picture

Tested #31, changes are visible
This can be moved to RTBC

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

kevinvb’s picture

StatusFileSize
new2.97 KB

Tested #31 but seems the patch is splitting up the old variable leaving some non-functional JS.

Created a patch from the one in 31 which also removes the 2 lines

'aria-required': 'true'
}).closest('.js-form-item, .js-form-wrapper').find(label);

This fixes console errors like Uncaught SyntaxError: Unexpected token ':'

djsagar’s picture

Status: Needs review » Needs work

@KevinVb please review as this is "Custom Commands Failed".

Thanks!

kevinvb’s picture

Status: Needs work » Needs review

@djsagar
Patch was created on 9.1.3 and worked. It was first patched with #31 which broke ckeditor and entity browser when JS aggregation is applied.
If someone could test this in 9.2 it would be really appreciated but for now I can only say it works for me in 9.1.3

sime’s picture

Update to Drupal 8.9 patch in #21. Some nested elements elements in webforms were not finding the .js-form-item wrapper with parentNode.

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.

kim.pepper’s picture

Issue tags: +#pnx-sprint
colin.eininger’s picture

Status: Needs review » Needs work

@KevinVb
It seems that states.js does not reflect changes in states.es6.js in your patch.

states.es6.js lines 690 and 691

const $child = $(e.target).closest('.js-form-item').find('label, legend');
const variable = $child.length ? $child.first().prop('tagName').toLowerCase() : '';

states.js lines 342 and 343

var child = e.target.parentNode.querySelector('label, legend');
var variable = child ? child.tagName.toLowerCase() : '';
yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar

Working on it

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.85 KB

Adding patch as previous patch failed to apply.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
StatusFileSize
new1.53 KB
new2.87 KB

Adding updated patch with an interdiff.

colin.eininger’s picture

Status: Needs review » Needs work

Thanks @yogeshmpawar for your work. The patch #42 seems good but in the patch #44 you changed :

.find(variable + '.js-form-required')
to
.find('variable.js-form-required')

which seems wrong to me. Is it intended ?

colin.eininger’s picture

I just noticed that you're not using jQuery .closest() but Element.closest() method which is not available in IE.

Since Drupal 9 need to support IE I would recommend to use jQuery here.

colin.eininger’s picture

Assigned: Unassigned » colin.eininger
colin.eininger’s picture

StatusFileSize
new2.85 KB
new2.46 KB

Got some time to work on it. I used jQuery .closest() instead of Element.closest() to get it working on IE. And reverted back
.find('variable.js-form-required')
to
.find(variable + '.js-form-required')

colin.eininger’s picture

Assigned: colin.eininger » Unassigned
Status: Needs work » Needs review

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.

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.

mdolnik’s picture

There are still issues with the latest patches:

  1. Multi-value fields do not display an asterisk when required via states.
  2. Date fields have issues applying the asterisks properly.

I decided to attempt a slightly new approach in the states.js code which I have provided a patch for.

Basically the changes to states.js from the previous patch(es) are:

  1. I have simplified the discovery of the label to apply the asterisk to into a single (chained) lookup instead of having it divided it into multiple parts ($child / variable / $variable).
  2. The search for the form wrapper now only includes "visible" labels by ensuring the element does not contain the .form-no-label class.
  3. The querySelector() part is now broken up to easily identify the various types of label elements known to core.
  4. Fixed searching for legend to instead be legend > span in order to prevent certain issues where double asterisks were occurring.
  5. Added support for multi-value labels.
  6. Added support for date / datetime labels.
const $target = $(e.target);
const $label = $(e.target
  .closest('.js-form-item:not(.form-no-label), .js-form-wrapper:not(.form-no-label)')
  .querySelector(
    // Standard field labels.
    'label'
    // Labels within a fieldset.
    + ', legend > span'
    // Labels for multi-value fields.
    + ', th.field-label > .label'
    // Labels for date / datetime fields.
    + ', h4.label'
  )
);

This will result in the asterisk being placed on the closest "visible" label and not just the closest label it has found.

This helps for multi-value fields as the element/widget labels are often intentionally hidden (by WidgetBase::formMultipleElements()) so that we don't duplicate the field name for every delta. This new logic which will skip hidden labels will ensure that multi-value fields can now show the asterisk when required by states.

This also fixes other issues in fields with multiple sub-elements, such as formatted text fields, URL fields, etc.

This patch also includes fixes to formatted text fields by ensuring the .form-no-label is placed on its wrapper.

As for date fields, they currently have their own issues with how they are themed, this patch does somewhat help with the asterisks, but is not completely successful. This patch does however future-proof itself as the Issue 3078334 issue, when it's merged in, combined with this patch will fix *most* asterisk issues on date fields.

Multi-value fields before this patch:

Multi-value fields after this patch:

Formatted text fields before this patch:

Formatted text fields after this patch:

Date fields before this patch:

Date fields after this patch (plus latest patch from Issue 3078334):

mdolnik’s picture

StatusFileSize
new19.18 KB

Uploaded a new "before" image for the date fields in order to update the previous comment.

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.

mrdalesmith’s picture

Psatch doesn't seem to apply cleanly to 9.5, so I've rerolled.

nitin shrivastava’s picture

StatusFileSize
new10.69 KB
new3.93 KB

try to fix ccf in #55

herved’s picture

StatusFileSize
new10.22 KB

The reroll in #55 clearly went wrong, we get notices and it is not working at all.
Same for #56, which is not clear what it is trying to accomplish.

Here is a proper reroll of #52 for 9.5.x.

herved’s picture

StatusFileSize
new10.15 KB
new2.04 KB

Ah got it, #56 was attempting to fix the eslint errors.
This hopefully should work.

edit: Ok \Drupal\KernelTests\Core\Theme\ConfirmClassyCopiesTest tests are failing since text-format-wrapper.html.twig got changed here which changes the hash. This patch changes Stable and Stable9. Is that allowed? I was under the impression that it wasn't... I also notice that not all text-format-wrapper.html.twig files were changed (e.g: claro, bartik, etc).

herved’s picture

Status: Needs review » Needs work
lauriii’s picture

Issue tags: +Needs tests

It would be great if we could write some tests for this, just to make sure that this continues to work in future 😇

voleger’s picture

Issue tags: +Needs reroll

Needs reroll as in 10.0.x branch *.es6.js files exists anymore

_utsavsharma’s picture

StatusFileSize
new5.66 KB
new5.66 KB

Patch for 10.1.x.

prem suthar’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll +Needs Review Queue Initiative

Still needs test coverage so this is not ready for review yet.

fathima.asmat’s picture

Rerolled patch 54 to resolve warning "Undefined index: title_display in template_preprocess_text_format_wrapper".

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.

mdolnik’s picture

Related issues: +#3078334: Datetime and Datelist elements should render as fieldsets
StatusFileSize
new11.04 KB
new10.79 KB
new8.41 KB

Patch doesn't seem to apply cleanly to 9.5, so I've rerolled.

Sorry about my failing patch in #52 not sure why it was not applying when I submitted it.

It seems that many of the subsequent re-rolls have introduced issues or omitted patch changes that were present in #52 that are no longer present in the latest #65.

I have provided updated patch files for D8, D9, and D10/11 (10-1-x currently applies to both versions).

Patches 8.9.x and 9.5.x provide the same changes.

The main differences between 9.5.x and 10.1.x:

  1. Removes the states.es6.js which no longer exists.
  2. Removes the bartik template changes as the theme no longer exists.
  3. Removes the classy template changes as the theme no longer exists.
  4. Removes the seven template changes as the theme no longer exists.
  5. Removes the stable template changes as the theme no longer exists.
  6. Alters the new claro template to be changed in the same fashion as other templates.
  7. Alters the new olivero template to be changed in the same fashion as other templates.
  8. Alters the new stable9 template to be changed in the same fashion as other templates.
  9. Alters the new starterkit_theme template to be changed in the same fashion as other templates.

Besides the re-rolling only a single change has been made to states.js which is to add the lines:

// Labels within a summary.
+ ', details > summary'
mdolnik’s picture

edit: Ok \Drupal\KernelTests\Core\Theme\ConfirmClassyCopiesTest tests are failing since text-format-wrapper.html.twig got changed here which changes the hash. This patch changes Stable and Stable9. Is that allowed? I was under the impression that it wasn't... I also notice that not all text-format-wrapper.html.twig files were changed (e.g: claro, bartik, etc).

I am not sure about this, I may need someone with more knowledge as to what is allowed to be changed when it comes to base theme templates.

Regardless whether it's allowed or not, one would need to make the same changes to overridden templates in their own themes as the title_display variable should be provided to all text-format-wrapper.html.twig templates, the theme will need to ensure that the value is utilize to add the form-no-label class or not.

To clarify on these template changes, these are only to fix asterisks on formatted text widgets, so if this needs to be cut from the issue then it's not the end of the world and can be manually fixed on a site-by-site basis.

herved’s picture

StatusFileSize
new8.95 KB

Created MR, took the patch from #67 (2912092-67-10-1-x.patch), fixed eslint, and one twig missing commas.
Attaching static patch for composer.

Tests still needed. I had a look but we cannot simply replicate in \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest, this needs fields on an entity form for every scenario (e.g.: multi-value fields, date fields,...). Also media library fields if possible, which is why I need this patch.

pcambra’s picture

StatusFileSize
new8.47 KB

This solved the issue for me in 10.5.2, for simple fields, however, entity reference fields don't show the *, I think the changes from #3342118: When an autocomplete entity reference is required via #states, no required marker is added should be incorporated here
Here's a patch for composer workflows.

pcambra’s picture

MR updated to include the parts from #3342118: When an autocomplete entity reference is required via #states, no required marker is added , credit should go to @penyaskito, @edmoreta and @leoenriquezp I think.

Also attaching a #2912092 + #3342118 patch for composer workflows for 10.5.2

pcambra’s picture

rob230’s picture

I think this work in #72 adds the required asterisk, but doesn't actually enforce it. So users can submit without filling in the field.

Or maybe that's expected. I know it says this in the docs:

Since states are driven by JavaScript only, it is important to understand that all states are applied on presentation only, none of the states force any server-side logic, and that they will not be applied for site visitors without JavaScript support.

godotislate’s picture

I think this work in #72 adds the required asterisk, but doesn't actually enforce it.

Have not tested, but in the MR I do see JS that is meant to add the required attribute to the HTML element. In which case, if it's working, browser HTML5 validation should enforce required fields to be entered, unless the form is set to novalidate.

dench0’s picture

StatusFileSize
new9.45 KB

11.3.1

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.

herved’s picture

I rebased the existing MR !12713.

If we search for form-required in core we can find all places that we want to actually target.
I don't think the current approach is the best though because it tries to match all those and hardcodes all selectors in states.js, while every theme can produce a different markup (template overrides etc).

I think it would be way more reliable to add an arbitrary class, say js-form-item-label to all those places (preprocess and twig). This way we can easily target that class in JS.
The downside being that all contrib and custom themes would need to add it as well ideally, but we can maintain backward compatibility by keeping the existing label selector as fallback, if we don't find our class.
This should cover all cases I believe (standard label, fieldset, details, etc) but in case it doesn't cover a specific use case, states.js uses state:* events on DOM document which allows themes and modules to react to state events.

So I created a new MR !14909 with that approach, any opinions/thoughts are welcome.

herved’s picture

StatusFileSize
new10.27 KB
new26.24 KB

Attaching both MR snapshots for composer.

shani maurya’s picture

StatusFileSize
new8.25 KB

#MR12713 is failing with Drupal 11.2.10 as this particular file https://git.drupalcode.org/project/drupal/-/merge_requests/12713/diffs#d... is not present in the Drupal 11.2.10

I have rerolled the patch to be compatible with D11.2.10

tinny made their first commit to this issue’s fork.

ioana apetri made their first commit to this issue’s fork.

herved’s picture

I suggest focusing on MR !14909, following up on #78.
Diagnosis and fix assisted by Claude Code below.

MR !12713

Unlikely to be accepted as it stands. It has no test coverage, asked for in #60 and #64 back in 2022. It hardcodes label positions that only describe core's own markup. And it regresses: closest() can return null and querySelector() is called on it unguarded.

TypeError: Cannot read properties of null (reading 'querySelector')

Repro: a field with '#title_display' => 'invisible' and a #states required, not inside a fieldset. The .form-no-label exclusion from #52 is deliberate, but nothing handles it matching nothing. The throw precedes the required attribute being set, so the field never becomes required. That case works on main today.

The filter changes are the same exclusion again: text-format-wrapper is a js-form-item with no label of its own, so it has to be taught form-no-label too. Every label-less wrapper in core and contrib needs the same treatment.

MR !14909

Each template marks its own label with js-form-label, which states.js looks for, falling back to label[for=...], so nothing depends on markup structure. JavascriptStatesTest covers the fieldset legend and details summary, and fails without the JS change, so contrary to #70 those two do not need an entity form.

The tradeoff from #78 stands: a theme overriding these templates gets no marker on legends or summaries until it adds the class, and plain labels keep working through the fallback. The frontend BC policy allows this ("We will change the markup and CSS that core generates for user interface and theme improvements").

herved’s picture

Status: Needs work » Needs review
herved’s picture

Status: Needs review » Needs work

Correction to my previous comment: testing MR !14909 against a real site turned up two cases it missed. I will fix those shortly and leave this in Needs work for feedback.
It cannot move to review with both MRs open and I would rather not force that decision here.