Home › Forums › General Issues › Form populated with previously submitted data…
We’ve setup a form for users to submit entries.
I was wondering if someone can tell me if it’s possible to have it so that when a user wants to amend some information that the form fields are populated with previously submitted data?
If so, how can I do that?
Thanks
I believe you can use the ‘post_id’ option to do it. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf_form/. So, it should be something like this:
acf_form(array(
'post_id' => 99,
));
Where ’99’ is the ID of the newly posted object.
I hope this helps 🙂
Hi James
Thanks for this.
From the information the link you sent I’m using
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
However I only want certain fields to be editable?
Can you tell me how to do that?
Thanks
In that case, I believe you can use the ‘fields’ option like this:
acf_form(array(
'fields' => array('field_1234567890abc', 'field_abc1234567890'),
));
Where ‘field_1234567890abc’ and ‘field_abc1234567890’ is the custom fields key.
Hope this helps 🙂
Hi James
Thanks for this… I think I’m nearly there…
One thing thought, can you tell when where I can find the custom fields key for each field please?
Is it possible to use field name instead?
thanks
You can get the field key by enabling the “Field Keys” option in the “Screens Options” section when you are editing a field group. I’ve attached a screenshot for your reference. If you use the free version, you can do it with the “Show Field Key” option.
I hope this helps 🙂
Hi James…
Thank you so much…
This works well…
I guess my next question would be.
Is it possible to use CSS to format these fields or is it just a list?
They all populate well but I’d like to split them up into different panels/containers…
Along with some extra text etc…
Is that possible?
Hi @bigfootnetworks ,
I am glad to have been of help.
About the CSS customization, that may be a little tricky, you would have to write you own custom CSS that will overwrite the existing one. Unfortunately, ACF does not provide any interface for the same, so, the only available option would be to manually implement the css by altering the template files.
Hope this helps.
Yes… Sorry…
I kind of meant that using the array it just places the fields on the page in order.
I’d like to be able to place each one of them into a div… which would them pick up from a custom css…
Is that possible?
thanks
If you need to surround the fields with HTML tags like div, I believe you can use the ‘acf/render_field’ action hook. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf-render_field/.
You can also target the already the generated divs if you want. Please check the HTML source code using the developer tools on your browser.
I hope this helps 🙂
The topic ‘Form populated with previously submitted data…’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.