Support

Account

Home Forums Add-ons Repeater Field Repeater Field created in Front End – Update Post to work

Helping

Repeater Field created in Front End – Update Post to work

  • Hi,

    I am creating a new post with repeater fields from front end using the update_field function. It’s working fine BUT in order for the values to be displayed in the single.php template file, I need to get in the post from the back-end and click update post.

    Example Code: (Is working fine, creating all the repeater fields)

    // Find the number of periods by reading the total number of arrival dates and create them in the new contract
    	$periods = count($_POST['arrival-date']);
    	update_field('contract_rates_period', $periods , $post_id);
    
    // Find the number of rows by reading the total number of roomtypes and create them in the new contract
    	$rows = count($_POST['roomtype']);		   
    	for ($i = 0; $i < $periods; $i++) {
    	    update_field('contract_rates_period_'.$i.'_rate', $rows , $post_id);
    	}
    
  • The reason is that no fields or values are created until you update a post.

    Are you using acf_form() to show a front end form or are these fields from something you’ve build yourself?

    Or maybe I’m confused. Can you give more details on how on the form and process you’re using.

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

You must be logged in to reply to this topic.