getgrav / grav-plugin-email

Grav Email Plugin
http://getgrav.org
MIT License
37 stars 29 forks source link

Scroll down to contact form at modular page or dedirect to specific URL after submitting the form #132

Closed githubtobi closed 4 years ago

githubtobi commented 4 years ago

Hi there,

is there a possibility to scroll down to the specific anker tag where the contact form at a modular page is nested (www.domain.com/en/start#contactform) or to setup a URL redirect after the form was submitted?

Background: When the contact form is nested at the very bottom of a modular page and the user presses the "submit" button, the page will reload but not scroll down to the contact form. So the user can not see the "message was delivered successul" message.

Some Testing (with modular pages): "display: /start/contact_form" - not working "page not found" "display: /start/contact_form/thankyou" - Created a "thank you" page under the "contact_form" modular page. This is working & the thankyou page is shown. But this is not what I am trying to solve. This could be a workaround for the beginning.

Another idea: is it possible to change the css to display the "message was delivered successul" message with css style "position: absolute; top: 10px; z-index:1000" so it will be visible at the very top after reloading. the "success" div doesn't come with any class or id so I can't reference to it.

localnetwork commented 4 years ago

Hi @githubtobi ,

I think this is the wrong repo for this issue. But let me answer your question First, you need to add an ID to your modular section and change the "action" to your form to:

form: action: /your-page#yoursectioncontactform

to change the success message you need to add 'message' in the process action to your form

example: form process: captcha: true save: fileprefix: contact- dateformat: Ymd-His-u extension: txt body: "{% include 'forms/data.txt.twig' %}" email: subject: "[Site Contact Form] {{ form.value.name|e }}" body: "{% include 'forms/data.html.twig' %}" message: Your custom thank you message.

If you want to float your success message, just use position: fixed; instead of absolute and target that class to your css file.

localnetwork commented 4 years ago

@githubtobi example form here: https://learn.getgrav.org/16/forms/forms/example-form

githubtobi commented 4 years ago

form: action: /your-page#yoursectioncontactform

work like a charm - thanks!