Support

Account

Home Forums Bug Reports Flexible Content Fields with local json save out of order Reply To: Flexible Content Fields with local json save out of order

  • We can confirm that this issue is also occurring for us on ACF 5.8.3. We performed the following patch to /advanced-custom-fields-pro/includes/acf-field-group-functions.php:1029:

    
    /**
     * 20190809 MONKEYPATCH
     * There is a bug causing fields to lose their ordering specified in the local-json files.
     * The fix below addresses this until Elliot releases a fix.
     * See: https://support.advancedcustomfields.com/forums/topic/flexible-content-fields-with-local-json-save-out-of-order/
     */
    //             // Add field menu_order.
    //             if( !isset($count[ $field['parent'] ]) ) {
    //                 $count[ $field['parent'] ] = 1;
    //             } else {
    //                 $count[ $field['parent'] ]++;
    //             }
    
    //             // Only add menu order if doesn't already exist.
    //             // Allows Flexible Content field to set custom order.
    //             if( !isset($field['menu_order']) ) {
    //                 $field['menu_order'] = ($count[ $field['parent'] ] - 1);
    //             }
    /**
     * 20190809 BEGIN FIX FROM
     * https://support.advancedcustomfields.com/forums/topic/flexible-content-fields-with-local-json-save-out-of-order/
     */
                // Add field menu_order.
                if ( ! isset( $field['parent_layout'] ) ) {
                    if ( ! isset( $count[ $field['parent'] ] ) ) {
                        $count[ $field['parent'] ] = 1;
                    } else {
                        $count[ $field['parent'] ]++;
                    }
                } else {
                    if ( ! isset( $count[ $field['parent_layout'] ] ) ) {
                        $count[ $field['parent_layout'] ] = 1;
                    } else {
                        $count[ $field['parent_layout'] ]++;
                    }
                }
    
                // Only add menu order if doesn't already exist.
                // Allows Flexible Content field to set custom order
                if ( ! isset( $field['parent_layout'] ) ) {
                    if ( empty( $field['menu_order'] ) ) {
                        $field['menu_order'] = $count[ $field['parent'] ] - 1;
                    }
                } else {
                    if ( empty( $field['menu_order'] ) ) {
                        $field['menu_order'] = $count[ $field['parent_layout'] ] - 1;
                    }
                }
    /**
     * 20190809 END MONKEYPATCH
     * https://support.advancedcustomfields.com/forums/topic/flexible-content-fields-with-local-json-save-out-of-order/
     */
    

    We can confirm that this is the same thing posted by @hube2, and that it fixed the issue for us. Hopefully this information is helpful in developing a permanent fix, or to others who are testing the issue.