How can I customize form fields so that I can use my own layout but at the same time not lose all the logic and updates already built into the form plugin?
I’m using bootstrap and want to apply more classes at more levels than the outerclasses and classes fields currently offer. I was going through the bootstrap theme form fields but they look like cut down versions of the plugin fields which would then require a lot of manual maintenance to keep up to date. I want to keep the form plugin logic but have more control over the field layouts at the same time.
Is this possible? I’m not sure twig inheritance really allows this. Any suggestions? Thanks
You would need to add a twig path via a plugin event (pretty much every plugin does this… for example: https://github.com/getgrav/grav-plugin-breadcrumbs/blob/develop/breadcrumbs.php#L37-L40
Then you just need to copy and edit the appropriate form plugin’s twig templates: https://github.com/getgrav/grav-plugin-form/tree/develop/templates/forms/fields
You will want to ensure your event has a higher number than the form plugin’s, for example:
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 1000],
Make sure you keep the same directory structure and filenames the same.
could you please go into deeper detail how this is done?
What are the exact steps I need to do?
Where do I need to define this number for the event?
Thanks in advance!