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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.