Support

Account

Home Forums Bug Reports Field Group Ordering Incorrect on JSON Sync

Solving

Field Group Ordering Incorrect on JSON Sync

  • When importing the field groups from JSON, such as on a sync, the first subfield in the JSON array does not maintain its first position within its parent in the imported fields. It is moved to the end of the parent field.

    A recent change in acf_import_field_group seems to be the culprit with this addition

    
    // Only add menu order if doesn't already exist.
    // Allows Flexible Content field to set custom order.
    if( empty($field['menu_order']) ) {
        $field['menu_order'] = ($count[ $field['parent'] ] - 1);
    }
    

    When preparing the fields for sync, the incorrect menu orders are set to their position in the subfield array, which is zero. The call to empty returns true for the first item, but false for all remaining items, which moves the item to the end of its siblings. I believe this should be changed to a check if the key exists rather than empty.

    I can submit simplified reproduction steps if necessary. Our temporary work-around is to remove the conditional check for emptiness and set the menu order based on parents child count, as it was before the change.

    Thanks for looking into this!

  • hello,
    we encounter the same issue here… it’s quite a mess with lots of flexible fields!
    what is your workaround exactly?

  • 			
    if( empty($field['menu_order']) && $field['menu_order'] !== 0) {
        $field['menu_order'] = ($count[ $field['parent'] ] - 1);
    }
    

    Went for the pragmatic fix… 😉 In the short term, we’re just being careful not to overwrite it on version updates, and wait patiently for the fix.

  • Experiencing the same thing. When syncing fields to the database from the acf-json folder, the first field (usually an Accordion field type) in each of my flexible content layouts ends up at the bottom of the list.

  • the dev is aware of this issue and a fix will be in the next update. I posted a temporary work-a-round here. https://support.advancedcustomfields.com/forums/topic/flexible-content-fields-with-local-json-save-out-of-order/

  • When syncing fields to the database from the acf-json folder, the first field (usually an Accordion field type) in each of my flexible content layouts ends up at the bottom of the list. MyFirstPremierCard

  • Same issue… some of it still present in just released version 5.8.4 sadly.

    Top level items do not reverse order, but all items underneath repeater (and child repeater beneath it) are still flipping.

  • FYI we are also still seeing this issue, and we can confirm that the codefix provided by @jewella works.

  • Hi!
    We also still have this issue, it doesn’t seems to be resolved.
    We had an option page with 3 tabs and lots of fields in each tab… after a sync it was totally messed up!
    Is there a fix on the way?

  • It looks like this is fixed in the latest ACF release, as per patch notes:

    https://www.advancedcustomfields.com/blog/acf-5-8-5-release/

    *Release Date - 8 October 2019*
    
    * New - Added new choice "Add" to the User Form location rule.
    * New - Optimized acf_form() logic when used in combination with acf_register_form().
    * Fix - Fixed bug causing incorrect field order after sync.
    * Fix - Fixed bug reverting the first field type to Text in Firefox version 69.0.1.
    * Fix - Fixed bug causing tinymce issues when changing between block modes.
    * Fix - Fixed bug preventing block registration when category does not exist.
    * Fix - Fixed bug preventing block registration when no icon is declared.
    * Dev - Added RegExp compatibility for innerBlocks.

    I am currently downloading to verify locally.

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Field Group Ordering Incorrect on JSON Sync’ is closed to new replies.