Thanks its an unusual issue, I was lucky to catch it in the first place. I have fixed the issue by just disabling the service for the particular application. Thanks for the support.
Somehow its happening due to a Cache setting on the hosting platform. Whenever I disable Varnish(Caching option) on Cloudways platform it saves on the first go.
Otherwise if the caching is on it doesn’t save on the first submit just refreshes and then I have to make the changes again and submit then it works.
Any advice regarding this?
I have mentioned that I am using acf_form_head() and form tags to wrap the code.
acf_form_head();
get_header();
?>
<div class="sectiontlp" style="display:none;">
</div>
<div id="main" class="page editlistingtemplate">
<form action="" class="acf-form" method="post">
<div id="content">
<?php
print_r($_POST);
$builder = new BGC_Content_Builder();
echo $builder->content;
?>
</div>
</form>
</div>
Its working fine on my local machine somehow. Not sure what the issue is. I have followed the instructions for acf_form clearly as mentioned. I can see the data is fine in the $_POST variable its just not saving.
Editing an existing post.
I took an alternate solution for this using get_posts(), get_post_meta() to get the ids of my post type and the checkbox fields data and then comparing the meta with array_intersect() and in_array() for more accuracy.
This works better than the ‘LIKE’ operator which was giving me unexpected results.
Multiple “LIKE”‘s does not seem like a good choice for performance. I was thinking of going with two methods now
#1 Creating a duplicate entry of metadata as array in the postmeta through ‘acf/update_value’
#2 I was reading about creating a new field type https://www.advancedcustomfields.com/resources/creating-a-new-field-type/
I was wondering if there’s any way to save the checkboxes as an array instead of serialized data.
One final query, is there any way that I can hide same sub field in one section and show it in the other on the same page with multiple acf_form.
I understand what you’ve mentioned. This works but I’ve run into a bit of a mess here, is there any way that I can have multiple forms for the same group field with different forms containing different sub fields on multiple locations on the same page.
I hope I’m clear enough with my description.
Yes the fields I’m trying to get are subfields of a group field.
An example would be:
Group Field: Admin
Sub Field:
Label: Years in practice Type: Text
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.