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

Modular page form

Started by Muut Archive 11 years ago · 2 replies · 332 views
11 years ago

I've created a modular page and followed the instructions indicated in here http://learn.getgrav.org/advanced/forms#using-forms-in-modular-pages

I am able to show the form and the sending emails is working well, then sending emails stopped working when I made another test.

I'm not sure if I made something wrong that I did not spotted immediately.

Here's my current structure:-

a... I've created a modular page and created/used a page file form.html.twig
b... I've edited the modular markdown file as per instructions in the documentation and added the following:-

YAML
published: true
content:
    order:
        dir: asc
        by: default
    items: '@self.modular'
form:
    action: /01.home/_contact/thankyou
    name: contact-form 
    fields:
        - name: name
          label: Name
          placeholder: Enter your name *
          autocomplete: on
          type: text
          classes: form-name

        - name: email
          label: Email
          placeholder: Enter your email address *
          autocomplete: on
          type: email

        - name: subject
          label: Subject
          placeholder: Subject *
          autocomplete: on
          type: text

        - name: message
          label: Message
          placeholder: Message *
          type: textarea
          validate:
            required: true

        - name: g-recaptcha-response
          label: Captcha
          type: captcha
          recatpcha_site_key: 6LdUvhITAAAAANuC4X93GfyDX7LOPa7z68C4ESkV
          recaptcha_not_validated: 'Captcha not valid!'

    buttons:
        - type: submit
          value: Submit
        - type: reset
          value: Reset

    process:
    - captcha:
        recatpcha_secret: 6LdUvhITAAAAAA8FGshD4R5PL7yoCurL6xciXRwQ
    - email:
        from: "{{ config.plugins.email.from }}"
        to:
          - "{{ config.plugins.email.from }}"
          - "{{ form.value.email }}"
        subject: '[Contact form submission] {{ form.value.name|e }}'
        body: '{% include ''forms/data.html.twig'' %}'
    - save:
        fileprefix: contact-
        dateformat: Ymd-His-u
        extension: txt
        body: '{% include ''forms/data.txt.twig'' %}'
    - display: thankyou

At my site email configuration, I've used something like below configuration:-

Mailer: SMTP
Email from: [email protected]
Email to: [email protected]
SMTP server: localhost
SMTP port: 25
SMTP encryption: none
SMTP login name: [email protected]
SMTP password: password
Path to sendmail /usr/sbin/sendmail

Is there something wrong with my structure or is it the email configuration? Please help as I'm trying to work this out for about a day with no luck.

11 years ago

The rest of the form works fine? The values are saved to data/contact-form?

If that part ok, it might be something related to the email settings.

If not, the form.action param must be action: /home

11 years ago

Hi flaviocopes, the data are not saving as well. It's just redirecting to the thank you page with no action. There's an error when I tried to change the action path to "/" or "/home", but it saves the data and the email is working fine, but when I change the action path into the full path of the thank you page, there's no action, but the thank you page works fine. What is happening?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1350 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4061 9 years ago
Archive · by Muut Archive, 9 years ago
1 2948 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago