Home › Forums › Add-ons › Repeater Field › Dynamically generate subfield content when adding rows to a nested repeater › Reply To: Dynamically generate subfield content when adding rows to a nested repeater
Hi John, thank you for your reply and for your suggestions. I had just written you an extensive reply and edited it because the images appeared as broken, and now it seems to have vanished, so I’m writing it again! 🙁
I have changed the priority as advised, many thanks, however if I remove the extra depth in the nested repeaters, then my default Prices no longer appear. Instead, I get 19 Offers, all with empty Prices repeaters inside.
If I start with my current code, including the extra array depth, then I get a sinlge Offer repeater, with it’s nested Prices repeater containing the desired 19 rows, all populated with the desired dates:
This part works fine, so I understand that this part of the code is OK.
My problem is that I want to be able to press the ADD (+) button on the parent Offers repeater, so that it adds a new row, when we will find that one of the contents of the row is the Prices repeater, which I was to appear populated by default with these same 19 rows and their contents.
I’m guessing the only way to do this is going to be via jQuery, since I can’t alter the function of the ADD (+) button on the Offers repeater.
I have managed to add a custom event to this exact button simply by locating it using jQuery and then I can make an Alert with an array of all the default values that I want to stick in the new Prices repeater, after it has added 19 rows to itself. I don’t even know if this is possible. I suspect it is, but very, very complicated. Any help is greatly appreciated!
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!
© 2023 Advanced Custom Fields.