Home Forums Backend Issues (wp-admin) Populating nested repeater fields


Populating nested repeater fields

  • I can’t seem to figure out how to do this. I have a repeater Event Category, it has two subfields, Category, a select field and Events another repeater. In the Events repeater is an Event select field that needs to be populated based off of the Category select field.

    I have figured out how to populate the values for Event using the append js action when an Event is added.

    My problem is I can’t seem to find where I can reliably get the value of Event and its parent Category for values that are already saved to the db. For some reason acf/load_value doesn’t get fired.

    add_filter( ‘acf/load_value/key=bme_subfield_0002_0001’, array( $this, ‘load_value_for_field’, 10, 3 ) );
    public function load_value_for_field( $value, $post_id, $field )
    Debug::write_log( ‘The value is: ‘ . $value );
    return $value;

    acf/prepare_field seems to be too early(or late) to use, it doesn’t have a value in its array and the id for the field at this point is using acfcloneindex so I can’t determine which subfield I have.

    How can I parse these values to load the selects?

  • Ok, so for me Category is a taxonomy for the Event select which is a CPT. So what I did for this was using the PHP filter acf/load_field I populate the choices with all events this way I at least get the value onto the page. Then on the JS side I use acf.add_action('load_field/key=..., func) to find the parent Category and filter the choices there.

    This seems like a lot for what I’m trying to do but I couldn’t figure out a better way. Let me know if I’m missing something obvious.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Populating nested repeater fields’ is closed to new replies.