Contact Form on SoraArticle

Hi everyone

I’ve been trying grav for a while now and like it very much. I don’t have a local server and put everything directly on a test folder online with my provider. I still am having fights via FTP to find the proper folders now and then, but other than that I think I can manage.

I have an odd issue I cannot wrap my head around: I’ve played around with the Deliver Theme and with SoraArticle and decided to run with the latter. The main issue is, that I cannot for the sake of me make the contact form work. With the Deliver theme the mails were sent just fine. With SoraArticle I can’t seem to make it work. The settings of the mail plugin are identical that’s why I assume it is an issue with the theme.

I tried to compare the forms from both the themes and they appear to work completely differently.

I noticed the following behaviour:

  1. The form checks for required fields just fine and displays a callout if a mandatory field is missing
  2. Once I submit the form, it is emptied and I get no message confirmation and no rendering of the thankyou page
  3. The mail is not sent

Something I’ve noticed and that might have nothing to do with it. I changed the language in the site config to DE. All pages I’ve created fresh are marked with .de. The skeleton pages from the themes don’t have that. I’ve installed the admin plugin and tried to modify the below form.md to understand if there was somekind of validation error. Interestingly, after the modification the file was named form.de.md but didn’t change functionality.

As said, I don’t have the issue with the Deliver theme why I suppose it’s not the plugin. I re-installed SoraArticle from scratch, because I feared I have messed with files that I shouldn’t have touched, but the problem persists. Any help would be very much appreciated.

I went through http://learn.getgrav.org/forms/forms to understand if I missed something or if there might not be write permission on the user/data folder, but to no avail unfortunately. May I include my user/pages/03.contact/form.md if anyone could help me?

title: Kontakt
form:
    name: my-nice-form
    fields:
        - name: name
          label: Name
          placeholder: Geben Sie Ihren Namen ein
          autofocus: on
          autocomplete: on
          type: text
          validate:
            required: true

        - name: email
          label: E-Mail
          placeholder: Geben Sie Ihre Mail Adresse ein
          type: text
          validate:
            rule: email
            required: true

        - name: message
          label: Nachricht
          size: long
          placeholder: Schreiben Sie Ihre Nachricht...
          type: textarea
          validate:
            required: true

    buttons:
        - type: submit
          value: Senden
          classes: gdlr-button with-border excerpt-read-more

    process:
        - email:
            from: "{{ config.plugins.email.from }}"
            to:
              - "{{ config.plugins.email.from }}"
              - "{{ form.value.email }}"
            subject: "[Feedback] {{ 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: Vielen Dank für Ihre Nachricht. Für schnelle und einfache Abklärungen sind wir gerne telefonisch erreichbar!
        - display: thankyou
---

Just tried your form on a “sora article blog” skeleton, worked fine.

With no multilanguage. With a clean skeleton with no multilanguage does it work fine? If you remove the process.email field?

(I’m assuming all is running on the latest Grav and plugins releases as got from the site)

Thank you flaviocopes. I will try and report back. Yes, I am on the latest grav version with all plugins updated. I’m not quite sure if I understand the process.email removal. I will try that first and then with a clean skeleton (again) to see if it worked. Many thanks.

Hi there, thanks again for your help. I installed grav incl. admin plugin from scratch, then loaded sora article by overwriting existing files (skeleton) to have all sample data. Contact form works flawlessly here. I wonder now what I’ve messed up with my site so far that it is not working. I didn’t use multilanguage and didn’t modify any content on the fresh installation. I will try to copy the forms part from the new installation to the folder, where it’s not working? (I guess…)

Just to keep you posted: As soon as I modify /user/config/system.yaml and add languages supported de, the contact form won’t work anymore.

before adding German, the contact form will be available on mysite.com/contact and work just fine.

after the above change on system.yaml it will be called on mysite.com/de/contact

i tried to remove the language parameter, but it will kill all my content I’ve created so far and the contact form will lead to a server error once submitted. I assume I could remove the language parameter from the created pages, so that they will work properly?

Sorry to bother, but I just don’t have a clue =/ thanks for the help so far.

absolute_urls: false
param_sep: ':'
wrapped_site: false
reverse_proxy_setup: false
languages:
  supported:
    - de
  include_default_lang: true
  translations: true
  translations_fallback: true
  session_store_active: false 
  http_accept_language: false
  override_locale: false
---

Can confirm, enabling multilang kills it. Will look into it tomorrow.

Thank you very much flaviocopes, your help is much appreciated. No rush! Thanks and regards, Adre

So, I identified this problem on the Sora Article theme, which affected forms on language-specific pages: the theme was overriding the default Form Plugin code, and didn’t have the correct form action.

But no real change was made, so I removed that file: templates/forms/default/form.html.twig (https://github.com/getgrav/grav-theme-soraarticle/commit/bb20932cd168b43dec01fbf3e5ea45069ced151)

Delete that file yourself and let me know if now it works.

Dear flaviocopes, that made the trick, thank you very much. I had to remove the language parameter from the contact page form.de.md for it to work in the end after I had removed the file you mentioned above. With the language parameter the server would throw a mail error. Thank you very much again for all your effort and help!

Ok, will be included in the next theme and skeleton update!