Problem/Motivation
When we create any display mode and select any form mode entity type and after that leave the name field blank and save the form. The name field is mandatory but there is no indication sign is given on the name field in the form.
Steps to reproduce
1. Go to /admin/structure/display-modes/form
2. Click on Add form mode action button.
3. choose any Choose form mode entity type
4. Name field is mandatory but it lacks mandatory sign.
Proposed resolution
Make Name field required
Merge request link
https://git.drupalcode.org/project/drupal/-/merge_requests/6237
Remaining tasks
Review/Commit
User interface changes
Before Patch

After Patch

API changes
None
Data model changes
None
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | before.png | 84.52 KB | shweta__sharma |
| #18 | Screenshot at Jan 22 12-53-10.png | 62.98 KB | shweta__sharma |
| #8 | 3375406-8.patch | 577 bytes | kostyashupenko |
| #6 | 3375406 after.png | 13.14 KB | Harish1688 |
| #6 | 3375406 before.png | 12.13 KB | Harish1688 |
Issue fork drupal-3375406
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:
- 3375406-the-name-field
changes, plain diff MR !6237
Comments
Comment #2
indrapatil commentedHello @Gauravvvv
there are two options to consider for addressing the issue related to the "Name" and "Machine-readable" fields which are hidden in the Add form mode:
1.Make the "Name" Field Mandatory:
If the "Name" field is intended to be mandatory for creating a new form mode, you should add the necessary validation to enforce this requirement. Additionally, it would be essential to provide a visual indication (mandatory sign or asterisk) in the user interface to inform users that the "Name" field is required. By doing so, users will know they need to provide a value for the "Name" field before they can successfully create a new form mode.
2. Remove Validation for the Machine-Readable Field:
If the "Machine-readable" field is causing confusion or if it's not necessary to be mandatory for the form mode creation, you could consider removing the validation for this field. This would allow users to create new form modes without having to provide a value for the "Machine-readable" field. However, it's essential to assess the implications of removing this validation and ensure that it won't lead to unintended consequences or issues in the system.
Comment #3
vaibhav_arora commentedHi, I have added patch #3 and added sign (asterisk) also attaching screenshot for the same.
Comment #5
Harish1688 commentedreviewing this.
Comment #6
Harish1688 commentedHi,
Tested the patch 3375406-3.patch for the issue The "Name" field in the Add form mode is required, although it lacks any mandatory sign. after applying the patch issue was resolved, mark (asterisk) are showing on the required field (Name). attached the images for reference.
Testing Steps:
1. Install the Drupal 11.x set up and moved on the path '
/admin/structure/display-modes/form'2. click add form mode button and choose form mode entity type 'content'.
3. In the dialog box issue will be appear.
Before:

After:

Looks good for RTBC+
Comment #7
smustgrave commentedPatch no longer applies cleanly to 11.x.
Also wonder if a simple assertion could be added to check for the form-required class.
Comment #8
kostyashupenkoComment #9
smustgrave commentedIf we can add that simple assertion to make sure this field has the required class.
Comment #10
indrapatil commented@smustgrave we need to add an assertion for the Name field or Machine-readable field.
Comment #11
utkarsh_33 commentedMarking the fields as required is already been taken care in the Allow user to add display modes from respective field UI's. issue. I think we can ask for the test coverage on the same issue.
Comment #12
djsagar commentedComment #15
djsagar commented@Akhil Babu MR !6237 and patch #8 both are same can you please elaborate why created MR.
After applied patch #8 label is required.
Moving this to NW.
Comment #16
akhil babu@djsagar, Using a merge request is now the recommended approach in Drupal over a patch. I’m sorry for not adding a comment earlier 😬. I’ve also included a test as mentioned in #9.
Moving to Needs review
Comment #17
akhil babuComment #18
shweta__sharma commentedTested Merge request !6237 on Drupal 11.x and it looks good. Now the name field has a required asterisk icon.
Before MR -
After MR -
Comment #19
shweta__sharma commentedIssue summary Updated
Comment #20
nitin shrivastava commentedMoving into the RTBC +
Comment #21
longwaveNot entirely convinced the test adds any value here, but let's add it anyway now that it was written.
Backported as a bug fix to 10.2.x.
Committed and pushed f50c6a352d to 11.x and 46549a06b6 to 10.2.x. Thanks!