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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Render ajax response ( without template? )

Started by Mike F 8 years ago · 1 replies · 761 views
8 years ago

I'm using gravstrap plugin&theme wherein lies a contact form which plays nicely with the given layout. The gravstrap form simply POSTs to simpleforms.com.

I gave a go at creating a plugin to receive the POST and use my own mail system to email
the form, instead of posting to simpleforms.

I chose to POST via Ajax and i would like to render a simple HTML response to my "form-messages" div.

All of the information to send the email is available at "OnPluginsInitialized" and I
send email on that event.

So possible questions are:

1) Can i render a simple response at this point in the grav lifecycle?

2) How to tell grav to continue/cleanup and move on to the next request.
$e->stopPropagation() seems to skip remaining events but grav still wants
to render a page.

3) If the above in not a good idea, what other approaches might serve the
roll-your-own "simple" form approach.

4) If i had to use a template to render the ajax response where to put it?
or symlink to user/plugins/form/templates from my plugin's directory
my plugin route is /postmail

8 years ago

There's a "How to" in the docs about submitting forms via Ajax.

The upside of using the Grav Form Plugin is that you'll have full control of the message handling. The downside is adapting the design to match the Gravstrap theme. It's up to you which way you prefer.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago