Support

Account

Home Forums Feature Requests Automatic Data Grid generated by two Repeater fields

Solving

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?

  • Hi @malte-seidel

    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.

    Repeater data grid

  • Hi @malte-seidel

    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 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Automatic Data Grid generated by two Repeater fields’ is closed to new replies.