Support

Account

Home Forums Add-ons Repeater Field Insert sub field on repeater rather than updating the entire field?

Solving

Insert sub field on repeater rather than updating the entire field?

  • Hi there,

    I was wondering if there was a way of inserting a row on a repeater field rather than updating the entire field?

    The reason I ask is I have users in the front-end adding data to the repeater field, but if two users try to add data at the same time then using the below method could result in one users new data being overwritten by the other.

    $field_key = "field_000000000";
      
    $value = get_field($field_key);
    
    $value[] = array("sub_field" => $user_input_here);
      
    update_field($field_key, $value)

    is there a way of just inserting a sub field, rather than updating the entire field?

  • Hi @arctic360

    Unfortunately, at the moment, it is not possible to append a result to the existing data, however this is definitely something I will add into v5.

    Perhaps an append function of some sort.

    Thanks
    E

  • Thanks Elliot.

    I’m trying to be a smarty pants and develop a chat room using ACF.

    I’ve figured it out. Just have to hope no one tries to chat at exactly the same time 😀

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

The topic ‘Insert sub field on repeater rather than updating the entire field?’ is closed to new replies.