Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 -"
Comment | File | Size | Author |
---|---|---|---|
#2 | 2899920-search_api-boolean_filter.patch | 441 bytes | kfritsche |
|
Comments
Comment #2
kfritscheAttached 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
Comment #3
kfritscheComment #4
drunken monkeyThanks 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).
Comment #5
kfritscheIn 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.
Comment #7
drunken monkeyAh, OK, I seem to have misunderstood.
In that case, sure, let's do the same. Thanks!
Committed.