Home › Forums › Backend Issues (wp-admin) › Relationship field – filter choices with AJAX › Reply To: Relationship field – filter choices with AJAX
I’m probably as close as you’ll get to an answer to this. The only real way to filter a relationship field is to use the acf/fields/relationship/query
If I were going to do this I might use a relationship field for the first choice but I would probably use a select field for the second field, only because it’s a whole lot easier.
This example of mine shows how to populate other fields based on the selection in a relationship field https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-fields-on-relationship
This example shows how to populate the choices of a select field based on a selection in another select field https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example
Like I said, I don’t know how to modify the AJAX request that ACF makes for a relationship field or how to trigger that request when another relationship field is changed. More than likely it’s possible, depending on your JS skills and how much time you want to spend digging through ACF to figure out how.
Hope this helps in some way.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.