I'm trying to create a custom form on the front end so that logged in visitors can post their own content.
Using ACF pro and Timber.
In my page.php file I have
$new_post = array(
'post_id' => 'new_post',
'post_title' => true,
'post_content' => true,
'field_groups' => array(26), // Create post field group ID(s)
'form' => true,
'return' => '%post_url%', // Redirect to new post url
'html_before_fields' => '<div class="foobar">',
'html_after_fields' => '</div>',
'new_post' => array(
'post_status' => 'draft',
'post_type' => 'vlog'
),
'submit_value' => 'Create Post'
);
$context['vlogform'] = acf_form($new_post);
and in page.twig, I have placed
{{vlogform}}
The form renders - but its stuck in a silly place, not where I want it. Its stuck above the html element...
Any pointers?
Thanks, Rob
** Edit **
This doesn't work
$context['vf_form'] = Timber\Helper::ob_function('acf_form', $new_post);
but this does...
ob_start();
acf_Form($new_post);
$context['vf_form'] = ob_get_clean();
Materially, what is the difference?
Thanks, Rob
This might be a little late, but I've managed to fix this issue by using an argument that they have added recently. I found this googling for it, so for future seekers this might come in handy.
So, in the args array, add the following:
$args = array(
'echo' => false,
);