Support

Account

Home Forums Front-end Issues Can not create form using multiple acf_form

Solving

Can not create form using multiple acf_form

  • Hello,

    I cannot save a new post using multiple acf_forms.

    I am using acf_form in a customized style which requires me to split the form into a few different <div> elements.

    According to the support forum I found that in order to do that you must define 'form' => false in the acf_form() settings and add the form tag and submit input manually.
    (Here it states it clearly)

    I did that calling 2 different acf_form()’s with different field_groups, but after submitting the form it failed to create a new post.
    What is strange is that when I tried it calling only 1 acf_form it worked perfectly.

    <form id="post" class="acf-form" action="" method="post">
    
        <?php acf_form(array(
    						'post_id'  => 'new_post',
    		        'field_groups' => array(8),
    		        'form' => false,
        			));
    		?>
    
        <?php acf_form(array(
    						'post_id'  => 'new_post',
    		        'field_groups' => array(64),
    		        'form' => false,
    	    		));
    		?>
    
        <div class="acf-form-submit">
            <input type="submit" class="acf-button button button-primary button-large" value="Update">
            <span class="acf-spinner"></span>
        </div>
    
    	</form>

    After submitting I didn’t find any errors.

    Does anyone have an idea of why it would save 1 acf_form but not multiple?

    Thanks.

  • I found the problem. But don’t know how to fix it.

    After looking in the view-source of the page I found that there is a “form-data div” created for every calling of the acf_form function.
    <div id="acf-form-data" class="acf-hidden">.

    Once removing all these divs except the first one using the inspection tool in the browser, everything worked perfectly.

    The problem is that I don’t know how to define to the acf_form() how NOT to create unwanted extra data-form divs.

  • Have you tried doing a field group like this

    <?php acf_form(array(
    						'post_id'  => 'new_post',
    		        'field_groups' => array(8, 64),
    		        'form' => false,
    	    		));
    		?>

    the field_groups take an array maybe thats the issue.

  • I have a page that consists of over 5 ACF forms working fine. You need to make sure that:
    – all of your forms have the same arguments passed to acf_form
    – use ‘form’ => false for all except one

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

You must be logged in to reply to this topic.