Home Forums Add-ons Repeater Field Dynamically Populate Repeater Field


Dynamically Populate Repeater Field

  • Hello, I have a front end repeater field that has 2 subfields. I would like to add a button in the form that performs an action in the backend that automatically populates the repeater fields.

    I have done this successfully with other field types. However I haven’t been able to do it with repeater fields.

    I am using the acf/load_field and it works except that I have to click the Add Row button for the field to display the values.

  • You only need to dynamically load the repeater and not the sub fields.

    // set load value for repeater
    $repeater = array(
      // a nested array for each row
        // a value for each subfield
        // use field keys rather than field names
        'field_0123456789abc' => 'value for field', 
        'field_0123456789abd' => 'value for field',
        // etc...
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Dynamically Populate Repeater Field’ is closed to new replies.