Since we, and our clients, really would like to see Gravity Forms work with Frontity I’ve decided to take a shot at it.
At the moment I’ve hacked together a simple implementation inside a theme which directly uses the REST API of Gravity Forms (
/wp-json/gf/v2/) to get forms through a custom handler and send back submissions directly with
fetch. However this is not very developer friendly
And since I’m far from a skilled React developer to begin with it would be great to get some support and feedback on my journey to create a package which (of course) will be released to te public as soon as possible.
I did noticed something in the CF7 package (which I used for reference), which is the usage of processors instead of actually using the REST API (no idea if that exist for CF7).
So I was wondering if this would be preferred, or actually retrieving all the data from the REST API (after getting the form ID) would make more sense. To me the latter makes more sense, since it will allow both handling the form embedded in the content (get ID from HTML with processor) and manually placing a form with any ID in React without putting it in a page/post first.
Another thing I was wondering about is on how to make a package have it’s own components (since a lot HTML needs to be rendered), but give the developer implementing it the freedom to override them with their own structure and styling (without breaking the logic behind it).
As a PHP developer I’m used to hooking into existing code to modify (like WP filters) or override it
(dependency injection), and I haven’t figured out (yet) how to do that in Frontity/React, so if someone has an idea or two about this I’ll be very happy.
- I have a hacky, but working, implementation of Gravity Forms in Frontity, but will need some help and feedback to make it into a working package for Frontity.
- Which method of handling the form would be preferred? Processors to modify the forms rendered by WP, or a handler to retrieve the raw data from the REST API and ignore whatever WP does?
- Is it possible to build a package in such a way that the user can inject their own components (theme config) which override the components from the package?
Oh, and lastly, is there a decent guide on how to build packages? Because themes are relatively easy, but packages seem to be slightly more complicated and the amount of Frontity packages out there are still limited, so hard to use existing code to figure out stuff.