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.
Here is a Gist I created of our current code, as you can see its long, but I am splitting arrays out into functions in the hope its easier to manage https://gist.github.com/amityweb/0fb48ae5e9737b61c299c31e38a62dfc
I can probably remove a few more fields and relay on defaults to reduce code.
P.S. I know object orientated approach may help but when I’m in a rush I just create functions, but not sure if the OO approach addresses my question.