Support

Account

Home Forums ACF PRO Using ACF_FORM ('form' => false)?

Solved

Using ACF_FORM ('form' => false)?

  • In the documentation for ACF_FORM() there is the option 'form' => false,

    Can you direct me to an example of how this is used to “Add to an Existing Form”?

    What I am trying to accomplish is to create a front end Form/Page with a list of Posts, displaying a TRUE/FALSE field that can be modified (Checked/Unchecked) and saved all at once.

    If there is not build in functionality I am planning on building with PHP that embeds each individual post id in a hidden field and then FOREACH though the form and use UPDATE_FIELD. Of course using existing functions is my first choice.

    Thank you for the help.

  • The only difference between acf_form() with form set to true or false is the inclusion of the ‘<form>’ wrapper tags. Everything else about it works the same and the fields are saved in the same way they would normally be saved.

    Other than some topics you might be able to find on this forum, I don’t think there are any examples of using acf_form() this way.

    Not sure if that helps you or not.

  • Thanks John,

    I didn’t think ACF_Form allowed this.

    I ended up writing a function to handle this for me.

  • The only difference between acf_form() with form set to true or false is the inclusion of the ‘<form>’ wrapper tags. Everything else about it works the same and the fields are saved in the same way they would normally be saved.

    Other than some topics you might be able to find on this forum, I don’t think there are any examples of using acf_form() this way.

    Not sure if that helps you or not.

    This is incorrect information.

    I’m searching Google now for information on how it works, and it certainly doesn’t work like this.

    Not only do I have to manually add my own form tags, I will also have to add my own submit button. I have copied the setup for both form tags and submit inputs from the standard rendering of the form, but clicking submit doesn’t save the values and I get a query string in return that’s ridiculously long.

    Documentation is lacking here. Anyway, I’m adding this in case others are searching for this response and are mislead by the answer above.

    Will write more when I figure it out.

  • Most of the time when using acf_form() without form tags is because you want to add acf fields to an existing form on the site. When you want to do this you need to figure out how to call acf_form() inside the <form></form> tags of the other form. This may not always be possible depending on what is generating the other form and if there are any hooks available that allow you to insert additional information into the forms.

  • Thanks for responding, John.

    I don’t quite understand what you’re saying.

    My challenge is to make two forms post with one submit button. I set form => false on both, add my own form tags and submit button manually, and it doesn’t work. At all. (as described above)

    And there’s nowhere in the ACF docs that I have found where this is explained.

    If you know of any such resources, I’d love to be pointed that way

    thanks!

  • Hey Elvin! I just found this thread and I’m going through the exact same issue as you.
    I’m setting ‘form’=>false and wrapping my form in my own tags and submit button, but it just doesn’t save the values.
    I even went into the php file from the plugin to see what markup was rendered, but nothing special is done if form is set to false (aside from not rendering the tags).
    Did you ever find a solution?

  • @eivindfs you cannot make two separate forms post with a single submit button. All the submitted fields must be in the same form, that is all inside of the same <form...></form> tags.

    If this is the case then the first suspect is that you are not calling acf_form_head() before your header is output.

  • @hube2 I think that the issue is actually trying to “merge” two forms, as far as I understood @eivindfs.
    He did state that he set ‘form’=>false then wrapped his acf_form in the <form> tags.

    My challenge is to make two forms post with one submit button. I set form => false on both, add my own form tags and submit button manually, and it doesn’t work. At all. (as described above)

    It’s not that a single button will submit 2 forms, it’s that the acf_form is not being submitted or saved if the tags are not rendered by the function.
    Right now, I’m taking a look at form-front.php to see what I might be missing whenever I try to render it with ‘form’=>false.

    Even more interesting, if you use acf_form(), (without parameters), it works perfectly fine.

  • In either case I do not have enough information to figure out why it’s not working. If you are calling acf_form_head() in the right place then AVF sees that $_POST[‘acf’] is populated and saves the values to the post ID (or other ID as needed) that is submitted which is in an hidden ACF form field. If it’s all set up correctly then I’m sure that ACF is saving values somewhere but that somewhere my not be where you expect it do be depending on where ACF thinks it should save the values.

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

You must be logged in to reply to this topic.