Support

Account

Home Forums ACF PRO Is there something like a get_acf_form method?

Solved

Is there something like a get_acf_form method?

  • I’m trying to use ACF pro forms with Timber (a wordpress MVC framework). I have a problem in that the ACF form is being rendered above the html element – and not where I want it to be.

    I posted on stackoverflow http://stackoverflow.com/questions/42164388/acf-custom-fields-and-wordpress-timber-front-end-forms and Timbers author replied with:

    “The problem is that acf_form is also echoing when called in the PHP file. You can either look for an alternate function (is there something like get_acf_form that returns the HTML but doesn’t echo?) OR use Timber’s output buffer wrapper:

    $contect[‘vf_form’] = Timber\Helper::ob_function(‘acf_form’, $new_post);
    … this will store the data in the vf_form attribute, but not suppress it from echoing until called in Twig”

    So my question is, is there a method like get_acf_form that returns the HTML but doesn’t echo?

  • No, there isn’t. You will need to use a buffer as explained by the author of the framework you using.

  • Thanks. I tried the buffer code that he suggested – this didn’t work. So I went with:

    `ob_start();

    acf_Form($new_post);

    $context[‘vf_form’] = ob_get_clean();

    which did work. I find all this buffer stuff a bit weird.

  • What you did is what I would have done. I use buffers all the time, they can actually make life a lot easier when you get used to using them.

  • Thanks. I’m now trying to figure out how to uplaod files directly to Amazon S3. I built a prototype in node.js (its whats I know). PHP / wordpress is total new to me (hence using Timber – as it’s more in line with what I know). I built my first wordpress site last week. Glad I stumbled upon ACF 🙂

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

You must be logged in to reply to this topic.