I have created an exposed Date Filter for a Search API view. Its a exposed filter with grouped options. The filtering is working but I get the following notice.

Notice: Undefined index: type in Drupal\search_api\Plugin\views\filter\SearchApiDate->acceptExposedInput() (line 83 of modules/contrib/search_api/src/Plugin/views/filter/SearchApiDate.php).

Did some search for the error and found this core bug #2811887: Exposed date filter leads to a notice.

Seems that Search API also needs a variant of this patch https://www.drupal.org/files/issues/2811887-34.patch

Comments

kristofferwiklund created an issue. See original summary.

kristofferwiklund’s picture

StatusFileSize
new954 bytes

Here comes a patch for it

kristofferwiklund’s picture

Status: Active » Needs review

Please review.

Status: Needs review » Needs work

The last submitted patch, 2: undefined_index_type-2980903-2.patch, failed testing. View results

drunken monkey’s picture

Component: General code » Views integration
Status: Needs work » Needs review
StatusFileSize
new910 bytes
new810 bytes

Thanks a lot for reporting this!
However, the change in the parent class more looks like we shouldn't even need our custom workaround anymore? Patch attached.
(If we'd go with your patch, you've also mixed up the assignments and set $type twice, instead of setting $this->value['type'] = $type the second time.)

Status: Needs review » Needs work
borisson_’s picture

Status: Needs work » Reviewed & tested by the community

The fail is not related, but this patch looks solid! Great work, @drunken monkey!

  • drunken monkey committed 5f9d1d6 on 8.x-1.x
    Issue #2980903 by drunken monkey, kristofferwiklund, borisson_: Fixed...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for reviewing!
Committed.

Status: Fixed » Closed (fixed)

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