We have a repeater field to output “rows” on a website, then in the row you can add flexible content fields for the different content types. We have quite a lot of flexible content fields, with lots of options.
We decided to code this using PHP because its easier to add and remove content blocks when we create new sites.
The file becomes quite large and complex due to nesting arrays to create a repeater, then a flexible content field, then the flexible content layouts, then each of the layout fields themselves.
I am trying to split things out into functions to create the necessary field arrays to make it easier to manage.
So I just wondered if anyone else has an efficient way to create complex fields in PHP that makes it easy to create and manage.
I don’t think anyone has a best approach. With complex field groups and building them in php it has always translated into extremely complex code. I usually do everything in OOP, it’s the habbit I’ve fallen into, and even here it becomes complex.
I have not tried this, but you might want to take a look at it. It’s not really for me because I dislike adding layers of abstraction that I need to figure out every time I look at my code, but it may offer a different solution for you acf Component Field https://acf-component-field.gummi.io/. They also have a pro version I think.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users