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.

Forms & Blueprints

Help with Form plugin override

Solved by Hugo Oliveira View solution

Started by Hugo Oliveira 8 years ago · 1 replies · 663 views
8 years ago

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:

YAML
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.

8 years ago Solution

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.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1133 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 131 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 107 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 125 7 months ago