I’m currently working on quite a large project, basically I’m using your plugin to build another plugin. In the end I plan on exporting the fields and registering them in the plugin start up.
Anyway, I really need to have a repeating set of fields with conditional logic in these fields. I understand that this is on the to-do list and I’m not trying to push that issue. I understand the complexities involved so I figure this could be a while in the making and I’m looking at a creative way to work around it.
What I have is one instance of all the fields I need created manually through the ACF interface and the beginning of the export looks something like:
Since I am going to put this into the plugin I thought, rather than add every instance of all of the fields manually in the ACF editor, I would write a PHP script that loops enough time to create all the field I need, renaming things as needed, for example changing “Field 1” to “Field 2” etc.
The only thing I’m not sure about is the acf field “key”, can this be altered?
An example would be to rename the key field_51eb5127e3480 to
So the question is, would this work or is the field key something that needs to be left alone? If this will not work, is there any other way they can be altered? For instance can I generate my own unique id for this purpose?
I’d really rather not do the tedious work of adding every field manually and this is something that I could easily automate if I can change the key values.
Great, thanks for the reply. I’ll probably stick with slightly altering whatever was created as the key when the field was created. Easy enough to use a preg_match to grab the fields and then duplicate and alter.
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘question about field keys’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Clients need flexibility. Developers need a repeatable workflow that doesn’t have a steep learning curve. See how digital marketing agency Noiza found both with Advanced Custom Fields in our latest case study.https://t.co/BxQAy6COJt