0

When I am creating a filter on a field, the "is one of" operator is not available. What are the necessary condition for the "is one of" operator to be available for field.

I have seen an example in which the "is one of" operator is available for taxonomy values. What is it about taxonomy values that make the operator available for them?

  • 1
    It’s available for filter handlers that extend the InOperator class (or the D7 equivalent) – Clive Sep 1 '18 at 11:21
  • @Clive I am sorry but I have no idea what this means. It is the first time I have come across it. In the case of Drupal 7, what is the feature of taxonomy that makes it available for taxonomy fields – vfclists Sep 1 '18 at 11:55
  • 1
    It’s the way the code is written, taxonomy term filters just have that functionality. If your question is more “is there an admin form where I can enable this functionality for other field types?” then you’re out of luck, you’d need to code that sort of change – Clive Sep 1 '18 at 12:18
  • It looks to me like the operator comes into play where some kind of uniqueness of values is assumed for the field in question. If I create a field where the values come from a select list or some PHP code would that be likely to make the "is one of" operator available for the field? – vfclists Sep 1 '18 at 13:45
  • 1
    It’s available to certain types of field, its not based on uniqueness or anything like that. When you code the class for a filter handler, you have the opportunity to provide it with this functionality. When the taxonomy handler was written, they based it on a handler that has the “in” functionality. Other types of field also have it enabled, but I don’t know em all off the top of my head. Sorry I don’t really have another way to explain it – Clive Sep 1 '18 at 14:13
2

'Is one of' operator in views filter aka ORoperator in SQL, it is only available for list fields or fields with allowed values that means any field which has the select list, radio buttons, or checkboxes widget can have and use 'Is one of' operator in views filter.

Theoretically, any reference field or any list field should have 'Is one of' operator available in views filter.

  • I sort of worked it out, but it didn't work on a reference field they way I expected. There doesn't seem to be a way of specifying which field in the referenced entity is supposed to be unique for use in a filter, unless it is supposed to be the nid or some GUID field. For the time being I have created a select list populated by a query on the referenced entity I know to be unique – vfclists Sep 1 '18 at 22:16
0

It appears that Views Reference Filter is meant to be a fix for this, but there are a number of critical looking bugs on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.