Loading core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +7 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#limit_validation_errors' => [], '#default_value' => $configuration['sort']['field'], ]; if ($entity_type->hasKey('bundle')) { $form['sort']['field']['#states'] = [ 'visible' => [ ':input[name^="settings[handler_settings][target_bundles]["]' => ['checked' => TRUE], ], ]; } $form['sort']['settings'] = [ '#type' => 'container', Loading core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php +8 −2 Original line number Diff line number Diff line Loading @@ -101,9 +101,16 @@ public function testFieldAdminHandler() { $entity_type_id = 'node'; // Check that the type label is correctly displayed. $assert_session->pageTextContains('Content type'); // Check that sort options are not yet visible. $sort_by = $page->findField('settings[handler_settings][sort][field]'); $this->assertNotEmpty($sort_by); $this->assertFalse($sort_by->isVisible(), 'The "sort by" options are hidden.'); // Select all bundles so that sort options are available. $bundles = $this->container->get('entity_type.bundle.info')->getBundleInfo($entity_type_id); foreach ($bundles as $bundle_name => $bundle_info) { $this->assertFieldByName('settings[handler_settings][target_bundles][' . $bundle_name . ']'); $page->findField('settings[handler_settings][target_bundles][' . $bundle_name . ']')->setValue($bundle_name); $assert_session->assertWaitOnAjaxRequest(); } reset($bundles); Loading Loading @@ -143,8 +150,6 @@ public function testFieldAdminHandler() { $this->assertNoFieldByName('settings[handler_settings][sort][direction]'); // Third step: confirm. $page->findField('settings[handler_settings][target_bundles][' . key($bundles) . ']')->setValue(key($bundles)); $assert_session->assertWaitOnAjaxRequest(); $this->drupalPostForm(NULL, [ 'required' => '1', ], t('Save settings')); Loading Loading @@ -177,6 +182,7 @@ public function testFieldAdminHandler() { $this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings')); $this->drupalGet($bundle_path . '/fields/' . $field_name); $this->assertFieldByName('settings[handler_settings][filter][type]', '_none'); $this->assertFieldByName('settings[handler_settings][sort][field]', '_none'); // Switch the target type to 'node'. $field_name = 'node.' . $this->type . '.field_test'; Loading Loading
core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +7 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#limit_validation_errors' => [], '#default_value' => $configuration['sort']['field'], ]; if ($entity_type->hasKey('bundle')) { $form['sort']['field']['#states'] = [ 'visible' => [ ':input[name^="settings[handler_settings][target_bundles]["]' => ['checked' => TRUE], ], ]; } $form['sort']['settings'] = [ '#type' => 'container', Loading
core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php +8 −2 Original line number Diff line number Diff line Loading @@ -101,9 +101,16 @@ public function testFieldAdminHandler() { $entity_type_id = 'node'; // Check that the type label is correctly displayed. $assert_session->pageTextContains('Content type'); // Check that sort options are not yet visible. $sort_by = $page->findField('settings[handler_settings][sort][field]'); $this->assertNotEmpty($sort_by); $this->assertFalse($sort_by->isVisible(), 'The "sort by" options are hidden.'); // Select all bundles so that sort options are available. $bundles = $this->container->get('entity_type.bundle.info')->getBundleInfo($entity_type_id); foreach ($bundles as $bundle_name => $bundle_info) { $this->assertFieldByName('settings[handler_settings][target_bundles][' . $bundle_name . ']'); $page->findField('settings[handler_settings][target_bundles][' . $bundle_name . ']')->setValue($bundle_name); $assert_session->assertWaitOnAjaxRequest(); } reset($bundles); Loading Loading @@ -143,8 +150,6 @@ public function testFieldAdminHandler() { $this->assertNoFieldByName('settings[handler_settings][sort][direction]'); // Third step: confirm. $page->findField('settings[handler_settings][target_bundles][' . key($bundles) . ']')->setValue(key($bundles)); $assert_session->assertWaitOnAjaxRequest(); $this->drupalPostForm(NULL, [ 'required' => '1', ], t('Save settings')); Loading Loading @@ -177,6 +182,7 @@ public function testFieldAdminHandler() { $this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings')); $this->drupalGet($bundle_path . '/fields/' . $field_name); $this->assertFieldByName('settings[handler_settings][filter][type]', '_none'); $this->assertFieldByName('settings[handler_settings][sort][field]', '_none'); // Switch the target type to 'node'. $field_name = 'node.' . $this->type . '.field_test'; Loading