Home Forums Front-end Issues acf_form() within another form not working


acf_form() within another form not working

  • I’ve inserted acf_form() within another form in front-end, but when clicking on submit button the data inserted in acf_form are not saved.

    This is the full code:

    <?php acf_form_head(); ?>
    	$post_id = ($_GET['i']);
    	$post_info = get_post($post_id);
    			<form id="pin-edit-form">
                            echo pinc_wp_editor('pin-title', ($post_info->post_title));
                    <h1> DESCRIPTION</h1>        
    						echo pinc_wp_editor('pin-content', ($post_info->post_content));
                     <h1> ACF NEW FIELD</h1>     
                            <?php acf_form(array(
                                'post_id' => $post_id,
                                'form' => false 
    <input id="pid" type="hidden" value="<?php echo $post_id; ?>" />
    <input  type="submit"  value="submit" /> 
    <?php } 

    Can anybody help me?
    Thank you!

  • I set 'form' => false because the form is inserted within an existing form and there is already a submit button. But maybe I’m missing something else?

  • Hi @gival146

    When you set 'form' => false, ACF won’t handle the form submission anymore, so you need to process the data yourself.

    You can update the custom field by using the update_field() function. To learn more about it, kindly check this page: Also, please don’t forget to use the field key instead of the field name for the selector.

    If you were using a plugin to add the existing form, then you need to execute the update_field() function when the plugin is saving the submitted data. In this case, could you please ask the plugin author how to execute custom code when it’s saving the form?

    I hope this helps 🙂

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

You must be logged in to reply to this topic.