This is not so much a support request or a new feature request as a request for guidance.
I have defined some metadata on a set of posts (which represent my client’s products) that I’m capturing with ACF fields; 3 fields represented as 3 separate drop-downs. For illustrative purposes lets say the three fields are
The three fields are displayed on the page as descriptive metadata with each post.
Fields 2. and 3. can be calculated from the first field. So rather than having the user input all 3 fields it would be better for the content-editor (and better for the accuracy of the data) if he/she was only required to input the first field and not all three. The template could then “calculate” the other two fields.
So my question is simply what is the best way to implement this?
For me a solution would be be adequate if
– the data for the 3 piece of data are editable in WordPress (I don’t want a hard-coded table defined in PHP, not least because the table of data will need to be updated now and again as more suburbs are added)
– ideally the 3 pieces of data are defined in one place (as one table for example).
Sorry if the solution to this is obvious!
This is a very interesting question and one which does not end with an easy solution.
Personally, I have created a similar interface by creating a new field type from scratch and storing all the postcode data in a table. You can find this kind of data from a google search and is widely available for free.
Most checkout software swaps the order of fields around and after selecting a country, the city dropdown is populated with AJAX data. Perhaps this is something you could think about coding?
Good luck with the field.
Had some more thoughts about this.
I’m trying to find a way I can do this which avoids a custom table, but which lets my client manage the table of data.
I realised that I can use the repeater field to capture the data and then query it in a template that spits out JSON. My templates can then query that JSON. So that’s awesome.
What would make this great however would be a select field that can be automatically populated with the unique key of the repeater field data, say Suburb.
That then creates the link between the lookup table (my repeater field) and the place where that lookup table is needed (say a page template for listing office locations for example).
The concept of a select field being able to be populated by an external source seems to have fairly broad application too.
What do you think?
Just to be clear this doesn’t necessarily given me those three interacting fields, but addresses the core requirement which is to normalise the data, provide a means to lookup data in a de facto table, and manage through wordpress the content in that de facto table.
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!
© 2019 Advanced Custom Fields. Subscribe