Support

Account

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.