Home › Forums › Front-end Issues › Adding a sub field to a repeater with JavaScript › Reply To: Adding a sub field to a repeater with JavaScript
Oups last solution failed in some cases…
But I think that this one is better and simpler (but not fully tested) ..
`// Get repeater field (replace my-repeater-field-key’ with a field key)
repeater = acf.getField(‘my-repeater-field-key’);
// Add a new row
$row = repeater.add();
// Get subfields
let sub_fields=acf.getFields({ parent: $row});
// show sub fields
console.log(sub_fields);
// loop around sub fields and populate them.
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.