How should the view data be defined when adding a custom filter to a field? How to add a custom views filter handler for a specific field? answers on how to add a filter to a base field.

I'm looking to add a filter to a non base field. (The field name is contact).

Here's what I have so far:

/**
 * Implements hook_views_data_alter().
 */
function custom_contact_views_data_alter(array &amp;$data) {
  $data['node__contact']['active_contact'] = [
    'title' =&gt; t('Active contact filter'),
    'filter' =&gt; [
      'title' =&gt; t('Active contact filter'),
      'help' =&gt; 'Filters node on active contact',
      'field' =&gt; 'contact_target_id',
      'id' =&gt; 'active_contact',
    ],
  ];
}


It is added, but it complains about group missing in the Views UI Error: missing group

How should the views data be defined when adding a custom filter to a non-base field?
You get the error Error: missing group.

You should be able to fix it by adding the group property, like this:

$data['node__contact']['active_contact'] = [
  'title' =&gt; t('Active contact filter'),
  'group' =&gt; t('Contact'), // Add this line.
  'filter' =&gt; [
    // ...
  ],
];