0

How do I use Drupal's core Views filter handler plugins on a custom views field?

I have a custom field which has its own FieldPluginBase Class. Does not have a DB query.

MYMODULE.views.inc:

/**
* Implements HOOK_views_data().
*/
$data['table']['date_field'] = [
  'title' => t('Date Field'),
  'field' => [
    'id' => 'date',
  ],
  'filter' => [
    'id' => 'date',
  ],
];
$data['table']['custom_field'] = [
  'title' => t('Custom Field'),
  'field' => [
    'id' => 'custom_field',
  ],
  'filter' => [
    'field' => 'date',
    'id' => 'boolean', // <--
  ],
];

How do I use this core views filter with a "pseudo field"?

  • 1
    You can't use that particular core filter, it's exclusively based on the database - you'll need to create your own filter plugin. Extending the current one as a starting point is definitely an option, but you'll need to override the various methods which plug it into the DB (at least query()) – Clive Apr 15 at 15:54

Your Answer

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

Browse other questions tagged or ask your own question.