Last active
May 26, 2021 17:14
-
-
Save chdenat/0f8e8bea236e218b598b6f8210257b0a to your computer and use it in GitHub Desktop.
Row creation in Javascript is easy ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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