Recently I was asked by an architect at a client to prove a persistent Gravity Forms form could be added programmatically with the possibility to maintain sorting and renaming labels of fields.
I’m sharing the basic proof of concept on how to programmatically add Gravity Forms for other developers because there is very little to be found on the topic. The code is by no means complete, the DocBlocks are there but they’re just the default automatically generated ones and the methods could be better. Alas, thats how quick PoCs tend to go.
I’ve posted the code as a Gist. Be my guest to use it. If there’s interest for it I’ll setup a Github repo.
The code is in form of a small plugin that provides a class to throw an array at. Here’s how you would do that:
Nice to see this topic gaining a bit of attention. Thanks.
Thinking of a framework that also remains client-friendly, that is: making the generated form editable in WP\’s dashboard.
Currently trying to get the pros and cons of Gravity Forms and co. Stumbled upon visual-form-builder which nicely covers most fields and is very accessible even for non-techies clients.
another post that could be spared. Not only VFB seems pretty dead, but I didn’t yet try GF to check if the generated form is editable from WP’s dashboard.
I wish gravity forms had better documentation and examples of how to achieve this!
I don’t think they have any docs and examples. It may very well be too much of an edge case for most users anyway.
Where would you put this file in the context of the Gravity Forms plugin?
You’d create a plugin for it. If you don’t know how to do that it’s best to learn how to create plugins first (or hire someone to do it for you).