Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Saving & syncing field groups

Koen edited this page Aug 1, 2019 · 4 revisions

By default, ACF stores all fields in the database. This doesn't work when you have multiple developers and environments. Therefore we're using the local JSON feature.

Saving as JSON

All updates to field groups are stored inside the acf-json folder inside the theme, and therefore the repository. This means they get spawned or applied as soon as the change became available in the application.

When to sync?

There is a distinction to be made between the spawned functionality in the templates/CMS, and when editing the field groups:

  • When deploying to a server, no manual synchronization is needed
  • In development, you'll need to sync changes made by others before making changes yourself. We've added a warning system when that's the case 🚨

The reason is that ACF will write whatever is stored in the current database to JSON. So if you're saving a field group that is unsynced, your changes will be saved to the JSON file. If there are unsynced changes, it won't write them alongside, and might overwrite the unsynced changes in the JSON file.

Caveats & final notes

  • If you pull new commits with changes to files in the ACF JSON folder, they will be immediately available for use in templates and the CMS.
  • They will NOT be visible in the overview of Field Groups. You will need sync them manually.
  • If you save fields locally, without having synced new changes first, you risk the chance of overwriting changes of others. Always check your changes, especially if they're made to huge groups like Flexible Content!
  • We've constructed a warning mechanism to warn developers if new changes are unsynced (see Grrr\Acf\SyncWarning).

Note: we've tried automated synchronization, but this has led to unexpected results, and doesn't play nice with multilingual or multisite setups.