-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Hi guys,
a problem I used to have in previous versions of sharp has reappeared.
A filter that has a value of 0 (for example an integer status where one possible state is represented by 0) is not recognized by the frontend and not handled properly.
If multiple are selected, including 0, then this works fine.
Examples:
https://example.com/admin/s-list/participant?filter_ParticipantsStatusFilter=0 gives No results found and shows no checkbox near option in filter
https://example.com/admin/s-list/participant?filter_ParticipantsStatusFilter=0%2C7 (two options selected in filter, included the one that has 0 as value) works fine
Previously this was solved on backend by checking for the query param.
My fix was done by overwriting the filter, but I think this should be upstreamed:
class StatusFilter extends SelectMultipleFilter
{
public function fromQueryParam($value): array
{
return ($value !== null) ? explode(',', $value) : [];
}
instead of
abstract class SelectMultipleFilter extends SelectFilter
{
public function fromQueryParam($value): array
{
return $value ? explode(',', $value) : [];
}
this is because for the operator ? : the value 0 evaluates to false and it is not passed further.
This should probably land in main so that noone shoots him/herself in the foot with "0" filters