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

https://git.drupalcode.org/project/drupal/-/merge_requests/6237

Remaining tasks

Review/Commit

User interface changes

Before Patch

After Patch

after-patch

API changes

None

Data model changes

None

Release notes snippet

Issue fork drupal-3375406

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

Gauravvvv created an issue. See original summary.

indrapatil’s picture

Hello @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.

vaibhav_arora’s picture

Status: Active » Needs review
StatusFileSize
new596 bytes
new179.93 KB
new180.2 KB

Hi, I have added patch #3 and added sign (asterisk) also attaching screenshot for the same.

Status: Needs review » Needs work

The last submitted patch, 3: 3375406-3.patch, failed testing. View results

Harish1688’s picture

reviewing this.

Harish1688’s picture

Status: Needs work » Needs review
StatusFileSize
new12.13 KB
new13.14 KB

Hi,

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:
issue image

After:
issue image

Looks good for RTBC+

smustgrave’s picture

Status: Needs review » Needs work

Patch no longer applies cleanly to 11.x.

Also wonder if a simple assertion could be added to check for the form-required class.

kostyashupenko’s picture

Status: Needs work » Needs review
StatusFileSize
new577 bytes
smustgrave’s picture

Status: Needs review » Needs work

If we can add that simple assertion to make sure this field has the required class.

indrapatil’s picture

@smustgrave we need to add an assertion for the Name field or Machine-readable field.

utkarsh_33’s picture

Marking 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.

djsagar’s picture

Title: The "Name" field in the Add form mode is required, although it lacks any mandatory sign. » The 'Name' field in the Add form mode is required, even though it lacks any indication of being mandatory.

Akhil Babu made their first commit to this issue’s fork.

djsagar’s picture

@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.

akhil babu’s picture

@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

akhil babu’s picture

Status: Needs work » Needs review
shweta__sharma’s picture

StatusFileSize
new62.98 KB
new84.52 KB

Tested Merge request !6237 on Drupal 11.x and it looks good. Now the name field has a required asterisk icon.

Before MR -

before-patch

After MR -

after-patch

shweta__sharma’s picture

Issue summary: View changes

Issue summary Updated

nitin shrivastava’s picture

Status: Needs review » Reviewed & tested by the community

Moving into the RTBC +

longwave’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Not 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!

  • longwave committed 46549a06 on 10.2.x
    Issue #3375406 by Akhil Babu, vaibhav_arora, shweta__sharma, Harish1688...

  • longwave committed f50c6a35 on 11.x
    Issue #3375406 by Akhil Babu, vaibhav_arora, shweta__sharma, Harish1688...

Status: Fixed » Closed (fixed)

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