I have an entity form that allows an admin to select a content type (checkbox) and an autocomplete field that is tapped into a VIEWS Entity Reference (via the Reference Method).

Goal: What I would like is to have the views entity reference filter dynamically change based off the end-user selection. Contextual Filters would have worked but I think Filters is better because of the multiple selection.

So far I have a view with entity reference and it is pulling the correct data for content 1-4. When I use the autocomplete it does what it's supposed to. I think the next step is to use AJAX to change how the autocomplete pulls from the view by changing the FILTER.

Can you help me figure out how I can change the views filter via AJAX/JS?

An example of what I am talking about


2 Answers 2


I am going to answer my own question in hopes this ccan help someone. However I am welcome to hear other options :)

What I ended up doing was attach a javascript that updates the autocomplete's path. Meaning when a user clicks on the checkbox it updates the input box for the autocomplete's attribute. The attribute called data-autocomplete-path. I appended a query string without messing with the functionality of it. This extra value gets sent to hook_views_pre_view.

This worked for me


The core issue for this is Add AJAX support to fields using Dynamic Views Arguments via Tokens, but at the time of this writing the only option available without custom coding is Business Rules' dependent field functionality.

However, there are still unresolved problems with multi-valued fields. See Multi-valued dependent child fields are not saved for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.