Skip to content

Instantly share code, notes, and snippets.

@chdenat
Last active May 26, 2021 17:14
Show Gist options
  • Save chdenat/0f8e8bea236e218b598b6f8210257b0a to your computer and use it in GitHub Desktop.
Save chdenat/0f8e8bea236e218b598b6f8210257b0a to your computer and use it in GitHub Desktop.
Row creation in Javascript is easy ...
/**
* Use this gist to add a row in a repeater field and retrieve all the sub fields you can manage later.
*
* @author : Christian Denat
* @email : [email protected] / [email protected]
*
* @date : 20210525
*
*/
// 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment