Support

Account

Home Forums Add-ons Repeater Field delete_row() function leaves empty row Reply To: delete_row() function leaves empty row

  • Hi @oleg-melnyk

    The delete_row() function will delete the chosen row, but won’t re-index the rest of the data. If you want to do it, you need to use the update_field() function instead. It should be something like this:

    $field_key = "rides_list";
    $post_id = $_POST['post_ID'];
    $value = get_field($field_key, $post_id);
    unset($value[$_POST['row_id']-1]);
    $value = array_values($value);
    update_field( $field_key, $value, $post_id );

    I hope this helps.