• Resolved JasonChou

    (@jasonchou)


    Hi All,

    I’m having an issue where when ever I make a change to either an ACF drop down box or checkbox (for taxonomy) all ACF postboxes on the post edit page disappears.

    I went and investigated and found the following:

    1: This only happens when editing posts using a frontend editor (Part of a Theme), editing in normal backend admin is fine.

    2: I noticed that whenever change is made to a checkbox or dropdown ACF adds and removes the class “acf-hidden” to all ACF boxes via “input.js”. In the backend, the class is added and removed without issues. However, when editing in the front end the “acf-hidden” class remains, hence hiding all ACF boxes.

    3: So in the front end editor after every change goes from:

    <div id="acf_8571" class="postbox[ ][ ]acf_postbox default">

    becomes:

    <div id="acf_8571" class="postbox[ ][ ]acf_postbox default acf-hidden">

    Whereas in the back end the “acf-hidden” is added and removed properly:

    <div id="acf_8571" class="postbox[ ]acf_postbox default">

    note: [ ] = space. In the frontend there are extra space in the class list, not sure if it’ll help narrowing down the problem.

    I’m getting around this (using a very dirty method) by changing the “acf-hidden” in “input.js” to something else to stop ACF boxes from disappearing in the mean time.

    What would be a better way around this issue, or perhaps a bug fix?

    Any help would be greatly appreciated. ??

    Cheers
    Jason

    https://www.ads-software.com/plugins/advanced-custom-fields/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Taxonomy fields are set up to refresh the form when they’re changed. This is a custom location rules thing. Normally this isn’t an issue, but in this case ACF can’t update the form because no location rules are matching. Because ACF is returning nothing to replace the form with, it displays nothing.

    Your two options are to create matching location rules or stop the form from updating. Unfortunately, if you create a rule so the form is allowed to show up on this page on the frontend, it will also show up on the admin side.

    My favourite way to stop the form from updating is to add data-save=0 to the taxonomy fields. I don’t know why that condition exists, I don’t see it used elsewhere in the code, but it works. Adding the attr with PHP would probably be best, but I haven’t figured out a way to do that yet. I’ve been putting this javascript on the pages I want to suppress updating instead:

    <script type="text/javascript">
    (function($) {
    	$(document).ready(function(){
    		$('.acf-taxonomy-field').attr('data-save', '0');
    	});
    })(jQuery);
    </script>

    Hopefully in the future we’ll be able to add rules like:
    If Page is equal to Register
    And Frontend is equal to true

    Hope this helps.

    Thread Starter JasonChou

    (@jasonchou)

    Thanks inspirationdate!

    Adding ‘data-save=0’ fixed it for me! You’re awesome ??

    Sorry for the extremely late reply too. :p

    Cheers
    Jason

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘"acf-hidden" class not removed error…’ is closed to new replies.