Add custom form in Admin Panel

It’s a pretty simple process to extend an existing page form. Or even add a simple ‘configuration’ form (like that for system/config/site.yaml).

However, if you want to create a completely custom ‘section’ of the admin with it’s own form storing it’s own data and doing it’s own thing, that’s quite a bit more involved. I really need to do an in-depth tutorial on this because it’s not so trivial I can outline it in a forum post.

I would suggest in the meantime to checkout a couple of plugins:

  1. The comments plugin: https://github.com/getgrav/grav-plugin-comments - this doesn’t actually have a form, it does have a .md page that it uses for authorization, and an associated Twig template to render a list of comments.

  2. The admin plugin itself: https://github.com/getgrav/grav-plugin-admin - This has several places where a form is built from a blueprint. That’s mainly done with this command:

This is where you pass the blueprint data to the partials/blueprints.htm l.twig to render out the form.

Then you need to have a task or method to validate and save the values.

This whole process is something we plan on providing some better ‘framework’ to handle going forward. For now it’s possible, but requires quite a bit of development. Luckily all the code you need is contained within existing plugins.