Loading core/modules/views/src/Plugin/views/filter/EntityReference.php +6 −7 Changes for core/modules/views/src/Plugin/views/filter/EntityReference.php: 6 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -360,14 +360,13 @@ public function validateExtraOptionsForm($form, FormStateInterface $form_state): */ public function submitExtraOptionsForm($form, FormStateInterface $form_state): void { $sub_handler = $form_state->getValue('options')['sub_handler']; // Ensure that only the select sub handler option is saved. // Unset sub handler settings that are not selected so they are not saved. // ConfigHandlerExtra::submitForm will set the selected sub handler's // settings. foreach (array_keys($this->getSubHandlerOptions()) as $sub_handler_option) { if ($sub_handler_option == $sub_handler) { $this->options['sub_handler_settings'] = $this->options[static::SUBFORM_PREFIX . $sub_handler_option]; } if (isset($this->options[static::SUBFORM_PREFIX . $sub_handler_option])) { unset($this->options[static::SUBFORM_PREFIX . $sub_handler_option]); $subform_key = static::SUBFORM_PREFIX . $sub_handler_option; if ($sub_handler_option !== $sub_handler && isset($this->options[$subform_key])) { unset($this->options[$subform_key]); } } } Loading core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php +13 −0 Changes for core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php: 13 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -99,6 +99,19 @@ public function testFilterUi(): void { $this->assertEquals($options[$i]['label'], $entity->label(), "Expected target entity label found for option $i"); $i++; } // Change Reference method to the test_entity_reference entity reference // view and ensure options are updated to only contain the one view result. $this->drupalGet('admin/structure/views/nojs/handler-extra/test_filter_entity_reference/default/filter/field_test_target_id'); $edit = [ 'options[sub_handler]' => 'views', 'options[reference_views][view][view_and_display]' => 'test_entity_reference:entity_reference', ]; $this->submitForm($edit, 'Apply'); $this->drupalGet('admin/structure/views/nojs/handler/test_filter_entity_reference/default/filter/field_test_target_id'); $options = $this->getUiOptions(); $this->assertCount(1, $options); $this->assertEquals('Article 0', $options[0]['label']); } /** Loading Loading
core/modules/views/src/Plugin/views/filter/EntityReference.php +6 −7 Changes for core/modules/views/src/Plugin/views/filter/EntityReference.php: 6 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -360,14 +360,13 @@ public function validateExtraOptionsForm($form, FormStateInterface $form_state): */ public function submitExtraOptionsForm($form, FormStateInterface $form_state): void { $sub_handler = $form_state->getValue('options')['sub_handler']; // Ensure that only the select sub handler option is saved. // Unset sub handler settings that are not selected so they are not saved. // ConfigHandlerExtra::submitForm will set the selected sub handler's // settings. foreach (array_keys($this->getSubHandlerOptions()) as $sub_handler_option) { if ($sub_handler_option == $sub_handler) { $this->options['sub_handler_settings'] = $this->options[static::SUBFORM_PREFIX . $sub_handler_option]; } if (isset($this->options[static::SUBFORM_PREFIX . $sub_handler_option])) { unset($this->options[static::SUBFORM_PREFIX . $sub_handler_option]); $subform_key = static::SUBFORM_PREFIX . $sub_handler_option; if ($sub_handler_option !== $sub_handler && isset($this->options[$subform_key])) { unset($this->options[$subform_key]); } } } Loading
core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php +13 −0 Changes for core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php: 13 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -99,6 +99,19 @@ public function testFilterUi(): void { $this->assertEquals($options[$i]['label'], $entity->label(), "Expected target entity label found for option $i"); $i++; } // Change Reference method to the test_entity_reference entity reference // view and ensure options are updated to only contain the one view result. $this->drupalGet('admin/structure/views/nojs/handler-extra/test_filter_entity_reference/default/filter/field_test_target_id'); $edit = [ 'options[sub_handler]' => 'views', 'options[reference_views][view][view_and_display]' => 'test_entity_reference:entity_reference', ]; $this->submitForm($edit, 'Apply'); $this->drupalGet('admin/structure/views/nojs/handler/test_filter_entity_reference/default/filter/field_test_target_id'); $options = $this->getUiOptions(); $this->assertCount(1, $options); $this->assertEquals('Article 0', $options[0]['label']); } /** Loading