A simple filter which allows to filter if a field is NULL/NOT NULL. This is very useful used together with views relationships, to just filter the list if the relationship is present or not, by exposing the operators "Is Empty", "Not Empty".
I just want to post the code for this handler here to share it with others, to may get a review and maybe to get something similar into views core. I was not able to do this with the current filters provided by views, but I guess it would be possible to modify the numeric filter. Maybe the option "Expose operator" could be refined to limit the operators to expose.
Comments
Comment #1
merlinofchaos commentedMost numeric filters already hand IS NULL/IS NOT NULL automatically when used on relationships. So the normal way to do this is to grab the primary field of the related data and add that filter. I don't think we need a specific filter for this situation.
Comment #2
osopolarI thought that we won't need this. I also have seen that option to add numeric filter to the primary field, but there are two things that I do not know how to achieve.
First: Change the Texts in the exposed filter select field.
Second: Hide the value field.
The only thing coming to my mind is to use hook_form_views_exposed_form_alter(). Is there a better way, or is it a good Idea to use the above filter in a custom module?
Comment #3
mustanggb commented