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.

General

Contact form - 400 display page not found

form

Started by Matt 8 years ago · 6 replies · 2063 views
8 years ago

Hi,

I've created a modular page with a contact form in it. The form sends the email OK, but for some reason, it gives a Server Error after it redirects to contact/_contact

Folder structure:

_Contact (form.md)
_showcase
_map
_Contactdetails (some icons, etc. no form)
thankyou
modular.md

modular MD:

YAML
---
title: 'Contact Form'
menu: Contact
onpage_menu: false
body_classes: 'modular header-image fullwidth'
form:
name: contact
fields:
    - name: name
      label: Name
      placeholder: Enter your name
      size: x-small
      autofocus: on
      autocomplete: on
      type: text
      validate:
        required: true

    - name: Company
      label: Company
      placeholder: Company
      autofocus: on
      autocomplete: on
      type: text
      validate:
        required: true

    - name: email
      label: Email
      placeholder: Enter your email address
      type: email
      validate:
        required: true

    - name: message
      label: Message
      placeholder: 'Enter your message'
      type: textarea
      validate:
        required: true

    - name: g-recaptcha-response
      label: Captcha
      type: captcha
      recaptcha_site_key: 134
      recaptcha_not_validated: 'Captcha not valid!'
      validate:
      required: true
buttons:
    - type: submit
      value: Submit
    - type: reset
      value: Reset

process:
    - captcha:
            recaptcha_secret: 1234
    - email:
        from: "{{ config.plugins.email.from }}"
        to:
          - "{{ config.plugins.email.from }}"
          - "{{ form.value.email }}"
        subject: "[Website] {{ form.value.name|e }}"
        body: "{% include 'forms/data.html.twig' %}"
    - save:
        fileprefix: feedback-
        dateformat: Ymd-His-u
        extension: txt
        body: "{% include 'forms/data.txt.twig' %}"
    - message: Thank you for your message!
    - display: thankyou

content:
items: '@self.modular'
order:
    by: default
    dir: asc
    custom:
        - _showcase
        - _contactdetails            
        - _map

---
8 years ago

Because you wrote display: thankyou, it will look for a page under your modular page (example: yoursite.com/contact/thankyou.
However, your thankyou page is at the root of your folder structure (if I can read it correctly).
To make it work, you therefore have to add a /.
This should work: display: /thankyou
More info here: https://learn.getgrav.org/forms/forms/reference-form-actions#display

8 years ago

Doh. as simple as that! Much appreciate 🙂

8 years ago

You are very welcome, if you have no other questions, you can mark this one as solved 🙂

Paul

8 years ago

How do i mark as resolved?

8 years ago

Hello,

At the end of the discussion, you have just to click on image|35x41

the button bar looks like : image|326x92

8 years ago

I dont seem to have that option? I'm using Firefox.

image|690x416

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 95 14 hours ago
General · by pamtbaau, 20 hours ago
1 61 19 hours ago
General · by Andy Miller, 1 day ago
0 47 1 day ago
General · by Marcel, 12 months ago
6 356 5 days ago
General · by Duc , 6 days ago
3 44 6 days ago