Home › Forums › Feature Requests › Automatic Data Grid generated by two Repeater fields
Before I do a real feature request ticket I would ask if the following scenario is possible with ACF PRO at the moment.
Lets say I do have two repeaters “Items” and “Properties”. Both repeaters consist of several fields like “Title”, “Description”, “Link URL” and so on.
I’d like to have an automatically generated data grid as a new input type. The definition of the data grid type is realised by selecting the two desired repeater fields plus selection of the field to be shown in the grid (e.g. Properties->Title as top row and Items->Title as left column.
I do hope my explanation is understandable. 🙂 Any ideas how i can do this with the current version of ACF PRO?
I’m afraid I don’t quite understand your request. Could you please share some screenshots of it? Maybe you can add some notes or sketch the example of the grid you want on that screenshots?
Thanks 🙂
Sure. Thank you for your patience!
I do have two repeater fields. Below those repeaters is the data-grid i am asking for. The grid should update automatically when i modify the repeaters in any way. Modifying means adding, editing or removing fields.
The grid is then filled with text or numbers. Whatever i define.
Thanks for the screenshot and the explanation.
There are two methods to achieve it, first by using Javascript and second by using PHP code.
The Javascript method will update the last repeater as you editing the other repeater. The problem is this method is hard to achieve. You need advanced JS code because ACF uses a complex code for the repeater field. If you want to do it, please take a look at this page to learn more about JS and ACF: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.
The PHP method is easier, but you need to save the page first before the last repeater is populated with the values. This method uses the acf/save_post hook and the update_field() to do it.
Here are some threads with the similar issue: https://support.advancedcustomfields.com/forums/topic/prepopulate-custom-fields-based-off-of-taxonomy/, https://support.advancedcustomfields.com/forums/topic/populate-flexible-content-rows-programmatically/.
I hope this helps 🙂
The topic ‘Automatic Data Grid generated by two Repeater fields’ is closed to new replies.
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.