Help with Form plugin override


#1

Hi everyone,

I am trying to customize a form on a site I’m developing using the Form plugin.

I have copied the default templates to my theme folder.
Initially the form was working fine. Somehow it stopped working and I can’t find the reason.
I fill in all the fields correctly and it just shows the default message (on a red background) saying “Please fill in all fields correctly!”.

Any ideas on what might be the problem?

My markdown file is as follows:

title: Contacts
slug: contacts
lang: pt
page_full_name: Contactos
menu: ‘Como nos contactar?’
page_background: /user/pages/images/back_contacts.png
email: (email address)
phone1: (phone number)
phone2: (phone number)
phone3: (phone number)
form:
name: contact-us
action: /contact-us
classes: ‘form-email row’
inline_errors: true
client_side_validation: false
fields:
- name: name
label: Nome
outerclasses: col-md-6 col-12
placeholder: Nome…
autofocus: on
autocomplete: on
type: text
validate:
required: true

        - name: email
          label: Email
          outerclasses: col-md-6 col-12
          placeholder: Email...
          type: text
          validate:
            rule: email
            required: true

        - name: message
          label: Mensagem
          size: long
          outerclasses: col-md-12 col-12
          placeholder: Mensagem...
          type: textarea
          validate:
            required: true

    buttons:
        - type: submit
          value: Enviar
          classes: btn btn--primary type--uppercase

    process:
        - email:
            from: "{{ config.plugins.email.from }}"
            to:
              - "{{ config.plugins.email.from }}"
              - "{{ form.value.email }}"
            subject: "Mensagem recebida"
            body: "{% include 'forms/data.html.twig' %}"
        - save:
            fileprefix: feedback-
            dateformat: Ymd-His-u
            extension: txt
            body: "{% include 'forms/data.txt.twig' %}"
        - message: Obrigado pelo seu contacto!
        - display: thankyou
cache_enable: false
process:
  twig: true
---

Preencha o formulário de contacto e envie-nos a sua mensagem. Se preferir falar directamente connosco, por favor utilize os contactos abaixo.


#2

Well, after additional testing I was able to figure out the problem.

I actually had 2 problems:

  • form action
  • interaction with the HTML theme I am using: basically the form was being processed by the theme’s JS instead of by the Form plugin

Correcting these 2 seemed to have done the trick.