• Hi Elliot,

    I’ve just upgraded to 3.5.5 and noticed that the conditional logic that used to hide non-appropriate fields in my Post Editor is no longer doing that. Not only is it not hiding them, but it’s also applying the requirement rules for fields that are supposed to be hidden and not applicable to the current selection.

    Check out this album at Imgur for more info. I’ve tried to show it as best I can, but if something’s not clear, please let me know.

    Thanks!

    http://wordpress.org/extend/plugins/advanced-custom-fields/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’m having the same issue. Please update us on this.

    Thread Starter daphatmac

    (@daphatmac)

    Looks like acf.conditional_logic.calculate isn’t being called for some reason. I’ll keep investigating & update this if I find a solution.

    Wondering if it’s something to do with the update to jQuery 1.8 in WP 3.5 and the deprecation of the .live() event handler.

    Thread Starter daphatmac

    (@daphatmac)

    I’ve changed the code for the conditional logic script generation to use .on() instead of .live() and it seems to work for me now. The only issue I have is that validation is still performed on fields that have been hidden by conditional logic. I would prefer if a field is hidden by conditional logic that any validation for that field is ignored (i.e., is_required etc).

    Here’s the code I’m using at the moment – although I’m hoping there’ll be a fix in the next update – this is around line 796 in acf.php.

    // conditional logic
    // - isset is needed for the edit field group page where fields are created without many parameters
    if (isset($field['conditional_logic']['status']) && $field['conditional_logic']['status']) {
    
        $join = ' && ';
        if ($field['conditional_logic']['allorany'] == "any") {
            $join = ' || ';
        }
    
        $if = array();
        foreach ($field['conditional_logic']['rules'] as $rule) {
            $if[] = 'acf.conditional_logic.calculate({ field : "'. $field['key'] .'", toggle : "' . $rule['field'] . '", operator : "' . $rule['operator'] .'", value : "' . $rule['value'] . '"})' ;
        }
    
        //do script
        echo '<script type="text/javascript">';
        echo '    (function($) {';
        echo '        var conditionalFN = function() {';
        echo '            var field = $(".field-'.$field['key'].'");';
        echo '            if('.implode($join, $if).') {';
        echo '                field.show();';
        echo '            } else {';
        echo '                field.hide();';
        echo '            }';
        echo '        };';
        foreach($field['conditional_logic']['rules'] as $rule ) {
            echo '        $(".field-'.$rule['field'].' *[name]").on("change", function(){';
            echo '            conditionalFN();';
            echo '        });';
        }
        echo '        conditionalFN();';
        echo '    })(jQuery);';
        echo '</script>';
    
    }

    I am not using WP 3.5.5, the only thing I updated was ACF and validation on hidden fields was broken.

    I have reverted back to 3.5.1 as I happened to have a local backup. Functionality is now restored. It’s hilarious that this falls under a ‘stable’ release.. it obviously wasn’t tested at all.

    Equally hilarious is the fact that older or archived versions are not available ANYWHERE on this site or at advancedcustomfields.com. This is absurd. When the end product like WordPress has a one-click upgrade button and nags, you need to provide a way to downgrade to ACTUAL stable versions, and in fact should keep iterations of each version of the plugin easily downloadable. Can’t believe such a popular plugin is not following best practices, or that WordPress’s plugin archive does not do the same given inherent fragmentation in this kind of environment.

    Thread Starter daphatmac

    (@daphatmac)

    That’s interesting – it must be a change in one of the JavaScript files then – oh, by the way, I found this today for the exact same reason!

    Let’s hope it’s not a major bug – it doesn’t seem to be, but it would be nice to be fixed soon 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Is conditional logic broken / changed in 3.5.5?’ is closed to new replies.