Support

Account

Home Forums Add-ons Repeater Field Adding subfields to Repeater Field Reply To: Adding subfields to Repeater Field

  • Thanks for the reply, I read the documentation. The problem is that if I insert a post the field isn’t created so I cant get the field key. The issue isn’t updating the repeater fields, or having a field key. The issue is adding to the field – I hope that makes sense.

    I am trying to work out a workaround, I am currently inserting dummy rows to at least make the entry appear in wp_postmeta using the following code:

    update_field('images','', $post_id);
     update_sub_field(array('images', 1, 'image'), '', $post_id);

    Here images is the repeater field, and image is the subfield

    If I check the database however, the field key doesn’t exist its just an empty string.

    SELECT meta_id, meta_key, meta_value FROM wp_postmeta where post_id=20963 AND meta_key like '%image%'

    You would expect this to return an entry with a field key however it returns this:

    mysql> SELECT meta_id, meta_key, meta_value FROM wp_postmeta where post_id=20963 AND meta_key like '%image%';
    +---------+-----------+------------+
    | meta_id | meta_key  | meta_value |
    +---------+-----------+------------+
    |  140515 | images    |            |
    |  140516 | _images   |            |
    |  140517 | _0_image  |            |
    |  140518 | __0_image |            |
    +---------+-----------+------------+
    4 rows in set (0.00 sec)

    The next step for me is to just do the query manually once I work out how ACF handles storing images in meta_value. This seems like a big limitation for anyone importing data and programatically inserting it into repeater fields, ive spend 2 days trying to find a work around 🙁 – I will work one out and post it here.