Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Custom processing in form: Can you give me a more clear example?

Started by Muut Archive 10 years ago · 1 replies · 441 views
10 years ago

Hi guys, I'm a bit confused about how develop my own processing task after the form submission, right now I need send the form's conten by email using sendgrid, then:

1) I need register the event 'onFormProcessed' but in which descendant class of Plugin must I define this?..for instance in the documentation this event is added inside the EmailPlugin.

Can I add this event inside the Form class?...or must I create my own class??

PHP
//could be something like this?
'onFormProcessed' => ['livedrive_handler', 0]

2) I write the handler for the event...the livedrive_handler

3) How can I include this in my process chain?...my process would be something like

TXT

process:
   - captcha:
            recaptcha_secret: ENTER_YOUR_CAPTCHA_SECRET_KEY
   - save: 
            fileprefix: feedback-
            dateformat: Ymd-His-u
            extension: txt
            body: "{% include 'forms/data.txt.twig' %}"
   - livedrive
   - message: Thank you for your feedback!

how can I achieve something like this?

thanks!

10 years ago

The example in the documentation is taken from the Email plugin. I suggest you to take a look at user/plugins/email/email.php and dissect the implementation of "onFormProcessed", dropping everything else and creating a sample plugin that implements a similar event, then customize it to provide your own form processing.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1354 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4065 9 years ago
Archive · by Muut Archive, 9 years ago
1 2953 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago