Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Process Type 'Hook' #29

Closed
sturple opened this issue Dec 15, 2015 · 1 comment
Closed

Add Process Type 'Hook' #29

sturple opened this issue Dec 15, 2015 · 1 comment
Assignees

Comments

@sturple
Copy link

sturple commented Dec 15, 2015

It would be nice to have a Hook Process to the form.
Not sure of how this would work, Would this have to be in the form of a function in your theme or another plugin
or would it be in the form of a custom function right in the yaml file
or is there somewhere else this could be defined.

Here are some reasons to add a hook

  • Be able to a email list registration, (curl call to another site)
  • Save data in a database
  • append to a custom file on disk instead of a new file each form submission
@flaviocopes
Copy link
Contributor

This is already possible.
See http://learn.getgrav.org/advanced/forms#form-actions

In the form process field add your own processing action name, for example 'saveToDatabase'.

Then in your plugin listen for the event onFormProcessed https://github.com/getgrav/grav-plugin-email/blob/develop/email.php#L22 and provide a handler for the saveToDatabase action: https://github.com/getgrav/grav-plugin-email/blob/develop/email.php#L57.

I posted those links that are from the Email plugin, it sends emails in this way, and you can add any action you can think of in your plugins / themes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants