cmrf_views: Allow dynamic OptionList filter values by optionally bypassing caching

Created on 14 October 2025, about 14 hours ago

Problem/Motivation

In CMRF views, OptionList filter values are determined when the CMRF Views Dataset's fields are loaded initially, and they are cached until manually cleared. This makes it impossible to use OptionList filters with values that may vary based on the options passed to the CiviCRM Views Dataset's getfields action.

Steps to reproduce

In Drupal, create a CMRF Views Dataset with some options relying on the currently logged in user, such as:

{
    "user_id": "[current-user:cmrf_key_authentication_field_id]"
}

In CiviCRM, create a matching getfields action that returns a choice/select filter with different options/values based on the presented user_id option. For instance, a missing user_id value could return:

{
  "values": {
        "test": {
            "name": "test",
            "title": "test",
            "description": "",
            "type": 1,
            "data_type": "Int",
            "api.required": "0",
            "api.aliases": [],
            "api.filter": true,
            "api.return": true,
            "options": {
                "": "All"
            }
        },
  },
  "count": 1
}

And a user_id value of 1 could return:

{
  "values": {
        "test": {
            "name": "test",
            "title": "test",
            "description": "",
            "type": 1,
            "data_type": "Int",
            "api.required": "0",
            "api.aliases": [],
            "api.filter": true,
            "api.return": true,
            "options": {
                "foo": "Foo",
                "bar": "Bar",
                "baz": "Baz"
            }
        },
  },
  "count": 1
}

As a result, in a view you'll never be able to see or use the foo/bar/baz values, even though you may be logged in as the user with ID 1.

Proposed resolution

Add the ability to refresh filter values when the view is loaded using a UI toggle in the exposed filter settings. When the "bypass caching" checkbox is checked, refresh filter values when values are requested.

Remaining tasks

None. Implemented in issue MR.

User interface changes

"Bypass caching" toggle added to exposed filter settings for CMRF Views OptionList filters.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

2.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024