Get select options for an entityreference field using another field as a contextual filter?
I've kept an eye out for a module that does this since the original post, but never came up with anything. I've been using a sort of "one off" solution to do this on a case-by-case basis instead:


In a custom module, implement hook_form_FORM_ID_alter() for the
form with your dynamic fields.
Add #ajax attributes to the first element to trigger and handle
changes to it with AJAX. This will specify the AJAX callback handler
and the HTML ID of the element to be replaced with the AJAX response.
In the ajax callback for that element, use the AJAX-submitted value
to dynamically get the appropriate values for the second value. For
me, this is usually a query of some sort with the submitted value as
a filter.
Update the second field's form element #options attribute with the
dynamic values and return the element.