Custom contact form as php post script in Grav

Hello there,

I am trying to bring a custom-made contact form to graph. It is made in PHP:
it gets the data from the UI-form via post then fires off either errors or an email and a success message. Pretty plain.

:thinking: Is there a way to make this run in/next to graph?
:nerd_face: I tried to just drop it in a folder. I get a 403 (Forbidden)
:exploding_head: Tried to do it as a plugin and found out: I don’t know how.

Can someone help me with a hint?

@joh, Did you have a look at Grav’s frontend forms?

If so, would you mind sharing which aspect of the custom-made contact form cannot be implemented by Grav’s forms?

@pamtbaau Oeps, maybe I should. Thanks! Will be back soon after checking this.

@pamtbaau I am struggeling. My markup of that form is quite unique. I cannot do in the frontmatter code since it does not allow to du custom divs and stuff. :-/

@joh, That’s a pity…

There are a few options:

  • There are common field attributes that can be added to each field, eg. to add ‘classes’ and ‘outerclasses’ with which you might fix a few things.

  • An other option is to override a form template. You can copy a Twig file from the form plugin (/user/plugins/form/templates/…) into you own theme (/user/themes/mytheme/templates/forms/…) and design your own layout.

    Theme Quark has overridden a few fields that way.

  • Wrap your custom form in a plugin. See tutorial and try again ;-).

  • Maybe someone on the forum can help you out if you don’t mind sharing the layout you require using pseudocode.

1 Like

@pamtbaau: thank you a lot for making that list.

Maybe someone looks for a similar thing. So I quickly talk about my solution:
In the end it became a version with the initially suggested frontend forms. I paired it with a custom JS that does the frontend validation.