From 46549a06b6f1ae4e14eaa5b37ff6603b9772265b Mon Sep 17 00:00:00 2001 From: Dave Long <dave@longwaveconsulting.com> Date: Sat, 3 Feb 2024 18:30:13 +0000 Subject: [PATCH] Issue #3375406 by Akhil Babu, vaibhav_arora, shweta__sharma, Harish1688, Gauravvvv, Indrapatil, smustgrave: The 'Name' field in the Add form mode is required, even though it lacks any indication of being mandatory (cherry picked from commit f50c6a352df6822e3d057d4d0bdbec8ef3725741) --- core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php | 1 + .../field_ui/tests/src/Functional/EntityDisplayModeTest.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php index 69525f0ae2ef..271294b9a288 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php @@ -87,6 +87,7 @@ public function form(array $form, FormStateInterface $form_state) { '#title' => $this->t('Name'), '#maxlength' => 100, '#default_value' => $this->entity->label(), + '#required' => TRUE, ]; $form['description'] = [ diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php index 130f559305e5..cd5bbfad27d4 100644 --- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php +++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php @@ -64,6 +64,8 @@ public function testEntityViewModeUI() { // Test adding a view mode including dots in machine_name. $this->clickLink('Test entity'); + // Check if 'Name' field is required. + $this->assertTrue($this->getSession()->getPage()->findField('label')->hasClass('required')); $edit = [ 'id' => $this->randomMachineName() . '.' . $this->randomMachineName(), 'label' => $this->randomString(), @@ -118,6 +120,8 @@ public function testEntityFormModeUI() { // Test adding a view mode including dots in machine_name. $this->clickLink('Test entity'); + // Check if 'Name' field is required. + $this->assertTrue($this->getSession()->getPage()->findField('label')->hasClass('required')); $edit = [ 'id' => $this->randomMachineName() . '.' . $this->randomMachineName(), 'label' => $this->randomString(), -- GitLab