Form Loading Values From Previous Entry
-
I have a form that submits a new post. Works fine. However, when I go back to that page to submit a new post, the values from the previous entry are pre-populated. I have not set any fields to load.
-
Hello,
Thanks for the feedback!
Yes this is the normal behavior of form submission. This feature is handled by your browser. The same bahvior can be seen on ww.wp.xz.cn for example, see video demo.
Hope it’s now more clear.
Have a nice day!
Regards.
Can I disable it? I want the form to be blank on the next submission. And to be clear, when I say go back, I didn’t literally mean go back in my history. I mean go to a few pages first, then go back to that page.
-
This reply was modified 3 years, 9 months ago by
Anonymous User 13711045.
Hello,
As explained in my previous answer, this feature is handled by your browser. You can try to make some research on Google about “chrome form autofill press back button” (if you use Chrome for example).
Hope it helps!
Regards.
I updated my previous response. I don’t literally mean when I press back. I mean when I navigate to that page again later on.
Hello,
What do you mean by “then go back to that page”. Do you click on a link that goes to the form? Then the inputs shouldn’t be prefilled.
Maybe you have some browser settings or plugins that prefill forms for you. I would recommend to disable all your browser plugins, or try a new browser, see how it behave.
Here is a video showing the form with empty inputs when visited thru a link.
Regards.
After digging, it’s happening because of the ‘acf/load_value’ filter. The post ID being passed to it is ‘acfe_form-16’.
Hello,
Which
acf/load_value? Is it in your code? Can you please be more precise?There is only 3
acf/load_valuein the whole ACF Extended code, and they are related to specific ACF fields advanced settings.The
acfe_form-16post id is normal, as it is generated on the fly during the form render to allow the injection of values based on the form configuration. This allow the same form to be rendered multiple times on the same page while having different loaded values if needed.If you use
acf/load_valueyou should always check which kind of$post_idit uses withacf_get_post_id_info()for example, since ACF have multiple post id types:$post_id 12 $id 12 $type post $post_id term_46 $id 46 $type term $post_id user_22 $id 22 $type user $post_id my-option $id my-option $type option $post_id comment_89 $id 89 $type comment etc...Hope it helps!
Regards.
Some more info, this is for a taxonomy term field. Line 1121 of field-taxonomy-terms.php has this…
$term_ids = wp_get_object_terms($info['id'], $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));The object ID being supplied is ‘acfe_form-16’. For whatever reason, this is returning previously submitted values.
The solution I found is to turn off ‘Load Terms’ setting for the taxonomy term field until this is fixed.
Yes, I wouldn’t recommend to enable the “Load Terms” setting on a field that is rendered on the front-end, otherwise the field will try to load the terms of the current front-end page.
Unfortunately, this is a limitation of the native ACF “Load Terms” setting (which is replicated from the ACF Taxonomy Field to the ACF Extended Taxonomy Terms field). It doesn’t make any difference between front-end and back-end.
Regarding the post id, see my previous answer for detailed explanations.
Regards.
Okay cool. Looks like
$object_ids = array_map( 'intval', $object_ids );in thewp_get_object_termsfunction is what is causing the issue. Was returning an array with a single value of 0. You can close this.Roger that, it’s done!
Have a nice day!
Regards.
-
This reply was modified 3 years, 9 months ago by
The topic ‘Form Loading Values From Previous Entry’ is closed to new replies.