Home › Forums › Add-ons › Repeater Field › Create New Repeater Row from Front End Form › Reply To: Create New Repeater Row from Front End Form
Hi Jonathan,
I think there is an update/change to the code that make the minus 1 to $new_repeater_count unnecessary.
looking in .//advanced-custom-fields-pro/api/api-template.php for ACF Pro v 5.4.2 – on line 1607 there is this.
if( is_numeric($s) ) {
// get row index
$row_i = intval($s) - 1;
// add to name
$name .= "_{$row_i}";
} else {
So it seems like the -1 is now built in the code.
I’m not too thrilled with this, as now I have to remember yet another hidden functionality to the update_sub_field() function.
I would update Jonathan’s code to something like this.
$repeater = get_post_meta($orgPost, 'org_users', true);
$index = (!$repeater) ? 1 : $repeater + 1;
update_field(ORG_USERS_FIELD_KEY, $index, $orgPost);
update_sub_field(array(ORG_USERS_FIELD_KEY, $index, ORG_USER_SUB_FIELD_KEY), $user_id, $orgPost);
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.