Home Forums Add-ons Repeater Field Dynamically populate a subfield within a repeater


Dynamically populate a subfield within a repeater

  • Hello,

    I am pulling data from an external api and I am trying to populate the custom fields with that data. So far I have been able to populate all the fields except the sub-field inside the repeater.. The structure is as follows:

    Field group
    – Repeater
    — Sub-field

            // The top level
            foreach ($fillable as $key => $name) {
                update_field($key, $ranking->$name, $inserted_ranking);
            // Repeater field loop, field_5f5f3d94277a3 is the repeater field id
            foreach ($fillable2 as $key2 => $name2) {
                update_field('field_5f5f3d94277a3', array('field_5f5f3d94277a3' => array($key2 => $ranking->team->$name2)), $inserted_ranking);
            // Sub-field inside the repeater, field_5f5fh3dd5277a9 is the sub-field id
            foreach ($fillable3 as $key3 => $name3) {
                update_field('field_5f5fh3dd5277a9', array('field_5f5fh3dd5277a9' => array($key3 => $ranking->team->localNames[0]->$name3)), $inserted_ranking);

    Why does the data populate within the first repeater but not the second(the sub field)? How can I access the third layer and populate it with data?

  • Correction for the sub-field, still does not work. I’ve read that sub-fields are prefixed with the parent repeater, should I select the sub field name prefixed together with the repeater fieldname? If so how would I do that?

            // Sub-field inside the repeater
            foreach ($fillable3 as $key3 => $name3) {
                update_field('field_5f5fh3dd5277a9', array('field_5f5f3d94277a3'=>array('field_5f5fh3dd5277a9' => array($key3 => $ranking->team->localNames[0]->$name3))), $inserted_ranking);
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.