Home › Forums › General Issues › Is my field/data structure correct? › Reply To: Is my field/data structure correct?
Question one:
That’s the easiest and fastest way to do it using fields. On the other hand, you could create a custom taxonomy that is hierarchical and then at the top level create the states and then on the second level you could have counties.
To do it with fields so that only the counties you want are loaded would take a lot more work, you’d need to create some custom javascript to reload the county select field whenever the state field was changed. Possible, but takes longer and the result from the users perspective will be the same.
Question 2:
I would also carefully name my county fields. If you are using the state abbr for the value of state then:
ia_county, nm_county, etc
then you can simplify getting the county
$county_field = $state.'_county';
$county = get_field($county_field)
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.