The "- Any -" Option for Boolean fields can't be saved as a view field value.

How to reproduce:

* Create a view
* Add a boolean field as filter
* Set new filter to exposed and not required
* Now you can select "- Any -" as default filter value
* Save view
* Open the boolean filter again
* You see the default value is now "True" and not the selected "- Any -"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kfritsche created an issue. See original summary.

kfritsche’s picture

Attached patch to fix this issue.

The "- Any -" value is internal "All", but the config schema states for filter_values: boolean, which overwrites this then to true.

Core is doing the same:

core/modules/views/config/schema/views.filter.schema.yml

views.filter_value.boolean:
  type: string
kfritsche’s picture

Status: Active » Needs review
drunken monkey’s picture

Thanks for reporting this!
Did you already create an issue for Core, too? Otherwise, please create one and, in any case, please link it here. For problems that also exist in Core, I usually try to go in tandem with the solution there, to stay as close to the original code as possible.
I actually see a second issue here: After adding the filter, but before saving the view, re-opening the filter config will actually show "False" as the default. Different problem cause, but same area, so you might want to add that to the Core issue (if there is one).

kfritsche’s picture

In my last comment with "Core is doing the same" I meant, it is already doing it like this and search_api should catch up. Thats why I added the part from the views schema from core afterwards.

drunken monkey’s picture

Status: Needs review » Fixed

Ah, OK, I seem to have misunderstood.
In that case, sure, let's do the same. Thanks!
Committed.

Status: Fixed » Closed (fixed)

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