Problem/Motivation
When editing a content type with a media field and the user makes an error, the message at the top of the screen shows that it has an
error but it does not highlight the field as with other fields
Steps to reproduce
Create a content type with a mandatory media field
Create a new item of content of this type but fail to add a media item.
Click on save and see that the error is reported at the top but that the field is not highlighted in a red border with red label text as other field types.
Proposed resolution
The 'error' class is added to the media field upon validation error, yet the associated styles for the 'error' class are not correctly applied. Update the CSS to fix the issue.
Remaining tasks
Update CSS to fix highlighting issue: DoneAdd a new test to ensure that 'error' class gets added properly to media field during validation errors: DoneTest: Done- Review
- Merge
User interface changes
Media fields are correctly flagged when in error.
Before patch

After patch

API changes
None.
Data model changes
None.
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | Claro-media-validation.png | 63.14 KB | sheetal.pathak |
| #35 | not-reproducable.gif | 4.8 MB | saurav-drupal-dev |
| #33 | Screenshot at Jan 03 11-21-55.png | 126.26 KB | shweta__sharma |
| #24 | After Patch.png | 93.46 KB | sandeep_k |
| #24 | Before Patch.png | 61.83 KB | sandeep_k |
Issue fork drupal-3396669
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 #3
rory downes commentedThe proposed resolution was wrong as it turns out. This class is being applied correctly. It needed some changes to fieldset and form styling to make sure that such a field has the star when mandatory and goes red when the has-error class is added by existing code.
I attach a patch to make these changes that worked for the site where I spotted this issue.
Comment #4
shweta__sharma commentedComment #5
smustgrave commentedThank you for reporting. Moving to 11.x as the current dev branch.
Could we have a simple assert to verify the classname is appearing correctly.
Comment #6
sir-arturio commentedTaking this on. (Hello from Drupal Contribution Sprints Helsinki!)
Comment #7
sir-arturio commentedWas able to commit the patch to the merge request(?) branch. Had problems setting up the contrib environment. Maybe next time!
Comment #8
rory downes commentedThis has been moved to the 11.x branch as that is the current dev branch. However, my patch failed to apply against 11.x and I have not had time to fix that
Comment #11
ameymudras commentedComment #12
smustgrave commentedWas previously tagged for tests which are still needed.
Comment #13
akhil babuComment #14
akhil babuComment #15
akhil babuAdded tests as per #5. Not sure why spell check is failing. No spell check error in local

Comment #18
smustgrave commentedMay need a rebase but other issues don’t seem to be having it so something that needs to be looked at before it can be merged
Comment #19
akhil babuThanks @smustgrave. Rebasig fixed the pipeline.
Moving to needs review
Comment #20
smustgrave commentedbefore/after screenshots should be included in Issue summary.
Tests pass without the change so either the test is off or the title is wrong, is the class not being added or is the styling not being added? Based on the answer will need a title/issue summary update to be clear.
Screenshots should be added either way.
Comment #21
gauravvvv commentedAdded before and after patch screenshot in the issue summary
Before patch
After patch
Comment #22
akhil babuComment #23
akhil babuThanks @smustgrave ,@Gauravvvv . The title was indeed incorrect. Updated the title and issue summary.
Moving back to needs review.
Comment #24
sandeep_k commentedVerified and tested patch MR !5371 mergeable on Drupal version- 11.0-dev. The patch was applied successfully and looks good to me.
Testing Steps:
Testing Results:
Now the media field is getting highlighted, sharing after patch results.
We can move this ticket to RTBC.
Comment #25
smustgrave commentedThen the test can be removed as it's not testing anything with this issue.
Comment #26
gauravvvv commentedComment #27
smustgrave commentedComment #29
quietone commentedI'm triaging RTBC issues. I read the IS and skimmed comments. The IS explains what this is about and there are before/after screenshots. All very helpful! I didn't find any unanswered questions.
This changes the UI so needs to be tagged for usability. I am adding the tag.
I tested this today on Drupal 11.x, standard install, using the steps in the issue summary. My results agree with what is in the issue summary.
There is a failing test,
Drupal\Tests\media\FunctionalJavascript\MediaSourceOEmbedVideoTestso I pressed 'rebase' in Gitlab which will start the tests again.Comment #30
shweta__sharma commentedMerge blocked needs to be rebased
Comment #31
gauravvvv commentedComment #32
shweta__sharma commentedRebased the MR
Comment #33
shweta__sharma commentedI tested on Drupal 11.x changes are done as mentioned in the Issue summary now the Media fields are highlighted during validation errors.
Attached screenshot for reference.
Thanks
Comment #34
nod_couple questions
Comment #35
saurav-drupal-dev commentedissue not fixed please check the attachment.
Steps followed
Create a content type with a mandatory media field
Create a new item of content of this type but fail to add a media item.
Click on save and see that the error is reported at the top but that the field is not highlighted in a red border with red label text as other field types.
Comment #36
sheetal.pathak commentedTested changes are done as mentioned the Media fields are highlighted during validation errors.
Versions tested on
Drupal - 11.x-dev
Drupal - 11.2
1. Set Claro theme.
2. Create a content type -> Add media field ->make it mandatory.
3. Create a new item of content of this type but dont add media item.
4. Save. Error is highlighted with red border.
Can be moved to RTBC+
Comment #38
quietone commentedThe Claro theme was approved for removal in #3576460: [policy, no patch] Deprecate and remove Claro.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3576668: [meta] Tasks to deprecate Claro and the removal work in #3584638: [meta] Tasks to remove the Claro theme.
Comment #39
smustgrave commentedClaro has moved to contrib