When adding a filter in Views UI, any AJAX trigger on an extra settings form will cause the dialog to go one step back rather than rebuild the current page.
This has been reported for a custom filter handler, but also blocks #2429699: Add Views EntityReference filter to be available for all entity reference fields.
Original report:
Motivation
I'm trying to make views filter plugin, that has an ajax dropdown select, which loads a different set of additional options depending on the selected choice.
If the ajax is triggered first thing after adding the filter criteria, the user is returned back to the "Add filter criteria" list, yet the filter is actually added.
Reproduction
To simplify the problem, I've made a simple module, that adds a filter with an ajax dropdown in the buildExtraOptionsForm function.
- Download and install the vaft module included in this issue.
- Create a new view.
- Add the VAFT Test. filter.
- Select a different option in the dropdown.
Instead of proceeding to the next settings form (which is empty in this simply test module), the user is returned to the "Add filter criteria" list.
However the filter is actually added. And if you open the settings up again (by pressing the bolded "Settings" in the filter), the ajax form works as expected.
Comments
Comment #2
birk commentedComment #4
panchoI can confirm this bug, which actually blocks #2429699: Add Views EntityReference filter to be available for all entity reference fields, so raising to major.
Copying over comment #193 by @_Archy_:
Also note that if aggregation is turned on, AJAX will jump back to the aggregation settings form, so it's literally jumping one step back.
Comment #5
panchoFound what probably is a workaround in EntityField. You just have to add:
$element['#ajax']['url'] = views_ui_build_form_url($form_state);This fixed our issue in #2429699: Add Views EntityReference filter to be available for all entity reference fields, too.
However I think that this should be solved more generically, so leaving this issue open, although maybe not as a major one anymore.
Comment #15
smustgrave commentedThis came up as the daily BSI target
The summary mentions a custom module but is this reproducible with straight Drupal?
If no follow up this could be closed in 3 months.