Drupal 9.
I have a content type with two entity reference fields.
The first entity reference field references group entities provided by the group module.
The second entity reference field references nodes of a certain type.
I want the second autocomplete to only find nodes belonging to the group selected on the first entity reference field.
What's the easiest way to accomplish this?
Edit: Still haven't found an easy way to do this. I'm currently looking at creating a custom entity reference plugin but I'm not sure how to pass in the value of the other field. The other possibility is to use the entity reference view option, but I run into the same issue there.
Edit 2: I found a way to make this work by using an entity reference view and modifying the ViewsSelection plugin method getDisplayExecutionResults
to add this:
if (isset($_POST['field_organization'])) {
$arguments[] = $_POST['field_organization'];
}
But this seems like a really flaky way to do what I want. Is there a better/safer way?