PHP warning when changing “Reference method” in Views EntityReference filter extra settings

Created on 23 August 2025, 15 days ago

Problem/Motivation

Changing the Reference method in any Entity reference Views filter via the filter’s Settings link (Configure extra settings) triggers a PHP warning during submit:

Warning: Undefined array key "reference_views" in Drupal\views\Plugin\views\filter\EntityReference->submitExtraOptionsForm()

Steps to reproduce

  1. Set up a fresh Drupal 11 dev site (includes Article and Page content types by default).
  2. Add an Entity reference field on the Page content type that references Article nodes.
  3. Enable the views_test_entity_reference test module (in core) or alternatively install the
    Views Core Entity Reference contributed module .
    This ensures the viewsDataAlter() hook exposes the new EntityReference filter.
  4. Edit the default Content view provided by core.
  5. Add the new entity reference field as a filter:
    • Select the Default reference method.
    • Restrict to the Article content type.
  6. Save the view.
  7. Re-edit the filter. Click the filter’s Settings link → open Configure extra settings.
  8. Change the Reference method to “Views: Filter by an entity reference view”,
    then click Apply and save the view.

Actual:
View saves successfully but PHP warning is logged:

Warning: Undefined array key "reference_views" in Drupal\views\Plugin\views\filter\EntityReference->submitExtraOptionsForm()

Expected:
No warnings; chosen reference method saves cleanly.

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBD

Introduced terminology

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

views.module

Created by

🇨🇦Canada tame4tex

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tame4tex
  • 🇨🇦Canada tame4tex

    So it looks like this PHP warning is also thrown when adding an Entity Reference filter and setting the Reference method for the first time. I have updated the IS to reflect this.

  • Pipeline finished with Success
    13 days ago
    Total: 2510s
    #581431
  • 🇨🇦Canada tame4tex

    I have opened MR 13079 that contains testing for the bug and the fix.

    Ready for review!

  • 🇨🇦Canada tame4tex

    This bug is preventing Functional Test from passing that set or change the Reference method in any Entity reference Views filter e.g. 🐛 Unable to get/set form_state values in SelectionPluginBase::validateConfigurationForm when called from EntityReference::validateExtraOptionsForm Active .

  • First commit to issue fork.
  • 🇺🇸United States smustgrave

    Had to rebase for the test-only job to run https://git.drupalcode.org/issue/drupal-3542769/-/jobs/6399689

    1) Drupal\Tests\views_ui\Functional\FilterEntityReferenceWebTest::testFilterUi
    Exception: Warning: Undefined array key "reference_views"
    Drupal\views\Plugin\views\filter\EntityReference->submitExtraOptionsForm()() (Line: 367)
    /builds/issue/drupal-3542769/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:55
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:209
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:158
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/TaskQueue.php:52
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:251
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:227
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:272
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:229
    /builds/issue/drupal-3542769/vendor/guzzlehttp/promises/src/Promise.php:69
    /builds/issue/drupal-3542769/vendor/guzzlehttp/guzzle/src/Client.php:189
    /builds/issue/drupal-3542769/core/tests/Drupal/Tests/DrupalTestBrowser.php:139
    /builds/issue/drupal-3542769/vendor/symfony/browser-kit/AbstractBrowser.php:378
    /builds/issue/drupal-3542769/vendor/symfony/browser-kit/AbstractBrowser.php:298
    /builds/issue/drupal-3542769/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:718
    /builds/issue/drupal-3542769/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:494
    /builds/issue/drupal-3542769/vendor/behat/mink/src/Element/NodeElement.php:176
    /builds/issue/drupal-3542769/vendor/behat/mink/src/Element/NodeElement.php:186
    /builds/issue/drupal-3542769/core/tests/Drupal/Tests/UiHelperTrait.php:112
    /builds/issue/drupal-3542769/core/modules/views_ui/tests/src/Functional/FilterEntityReferenceWebTest.php:108
    ERRORS!
    

    Which shows the coverage for the change being added.

    Trying to replicate following the steps, not using the contrib module though, I believe I'm able to see it. The change to submitExtraOptionsForm makes sense to me.

    LGTM

Production build 0.71.5 2024