- Merge request !26Issue #3552066: cmrf_views: Allow dynamic OptionList filter values by... → (Open) created by Unnamed author
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.
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
.
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.
None. Implemented in issue MR.
"Bypass caching" toggle added to exposed filter settings for CMRF Views OptionList filters.
None.
None.
Active
2.1
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.