I have a entity reference field that references a taxonomy term from a vocabulary named "fund". Now I'm needing to add a fiscal year field to the fund terms to allow us to have different budget lines for different fiscal years. Some of these funds will have the same name, but be from different fiscal years, so I now need to add a fiscal year dropdown list before the autocomplete entity reference field mentioned above.

Say the dropdown has two values FY17 and FY18, I'd like the views entity reference filter view to receive the selected value for fiscal year, and apply that as a filter to the views entity reference filter. How can I accomplish this? Alternatively is there a better way to accomplish this?

For example:

enter image description here

I looked at Dynamically change views entity reference filter based on current form value but it doesn't seem like it quite fits what I'm trying to do. I could be wrong.

  • Since the taxonomy field is dependent on the selected year, the solution will need to AJAXify the taxonomy ref view autocomplete field.
    – No Sssweat
    May 11, 2018 at 8:45
  • I've done something similar in the past where someone enters Zip Code then the Closest Dealer AJAX's in, where it shows the 3 Closest Dealer based on the zip code. Example. I utilized a view for the Closest Dealer where I dynamically pass it the Zip. Although, yours will require an extra step for the autocomplete functionality. Maybe I'll have time this weekend to write an answer.
    – No Sssweat
    May 11, 2018 at 8:56
  • @NoSssweat that would be really awesome. Since the autocomplete uses Ajax anyway I was hoping it might be a simple matter of grabbing the value of the select and passing it as an argument with the autocomplete Ajax call.
    – UltraBob
    May 11, 2018 at 9:13
  • The problem with that approach is that it would require you to save the node first, because when you're filling out the form Drupal does not know yet the year value until you hit save. So the real question is How can you grab the value of a node field that you're currently filling out and that doesn't exist yet?
    – No Sssweat
    May 11, 2018 at 9:14
  • My hope was that one could override the JavaScript function for sending the currently entered search text, to also grab the value from the dom and send it as an argument, but maybe you are saying that argument information cannot be sent along with the Ajax autocomplete request and needs to be prepopulated on the form?
    – UltraBob
    May 11, 2018 at 22:59

1 Answer 1


The simplest answer ended up being to use Entity Reference View Widget which allowed me to build a view for selecting the entity desired. This was nice because it allowed me to add some additional information and filtering the the approach I was hoping for in my question didn't allow. Unfortunately, it also moves me further from being able to update this site to Drupal 8 because this module doesn't exist for Drupal 8 because the maintainer decided to let another module that isn't released yet, cover this functionality for Drupal 8. I would still welcome answers about how to do this in a more forward compatible way.

  • I think this feature is in core now. I can simply choose a View with an entity reference display to get the entities from.
    – leymannx
    Dec 15, 2020 at 15:17

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.