StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
794 stars 62 forks source link

Migrating excisting field keys #183

Open wietsecats opened 10 months ago

wietsecats commented 10 months ago

We have a project with a whole bunch of ACF fields (in acf-json) which are linked to excisting content. We would like to migrate to acf-builder but the keys are generated automatically, so then we lose all the content. Doing a search-replace in the database is tricky.

We have managed for the fieldgroup to add the key to fieldbuilder so it generates the correct group key. but for fields it goes wrong because it adds the fieldgroup also to the field:

$builder = new FieldsBuilder('5def5ss7895b4s', ['position' => 'side', 'title' => 'Page options']);

current situation for a textfield: field_5def5ss7895b4s_634ec2238f005 desired situation: field_634ec2238f005

Is there a way to add manually a key 'key' => '634ec2238f005' when you add a group or field zo when can migrate. I cannot believe I'm the first to have this question :)

gustavo-roganti commented 9 months ago

@wietsecats can't you use the ->setCustomKey('') function for that?