Home › Forums › General Issues › Relations between field values
Working with ACF free version for a while, but now I’m searching for a bigger functionality, but can’t come up how I can do it with ACF.
I need to make relationship between two different fields and their values.
For example, there is field with countries as values. And other field – with cities. So, the user should have possibility to make his own cities (repeater in ACF pro) and make relationship with necessary countries (city -> country). Is it possible to do at all?
There’s an old tutorial with the similar topic, which you can see here: https://www.bobz.co/dynamically-populate-select-fields-choice-in-advanced-custom-fields/. Unfortunately, I’m not sure if it’s still working or not.
If you need the relationship, not just assigning a value to another one, then I suggest you create custom post types instead. That way you can use the relationship field or post object field to create the relation between the two object.
I hope this makes sense 🙂
Thanks for the answer @james
Unfortunately, this doesn’t solve my problem, because countries and cities was just head of the tree, there’s also should be possibility to assign address to city, then date to address etc. Quite a big a tree.
I reconsider my first question, and, sorry, I did a mistake in it. So, the country should be like post, and then, in that post, custom fields with cities, addresses, dates as values. Then, it should be possibility to make endless quantity of values (repeater, I know), and possibility to assign (or make relationship) address(es) to specific city. Then – date(s) to address. So, city should have many addresses, and after that, address should have many dates.
Custom post types can’t help here, imo, because it’ll be too complicated for user.
Reading your explanation, I think you can achieve it by using the nested repeater. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/working-with-nested-repeaters/.
But I’m not sure if this is what you want. If it isn’t, could you please explain to me what’s lacking from that method?
Hm. Probably, this can solve my task, but not sure… Don’t have pro version at the moment (sadly, this doesn’t depends on me), so can’t say anything without testing it. Also, can’t find any trial version of ACF pro, so should wait a bit.
You must be logged in to reply to this topic.
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!
Plugin boilerplates can do some of the heavy lifting during initial development. We look at four options to speed up your plugin creation. https://t.co/ZtMsdBxAHw— Advanced Custom Fields (@wp_acf) June 5, 2023
© 2023 Advanced Custom Fields.