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.

Content & Markdown

Contact Form and many questions

Started by mauro 9 years ago · 1 replies · 854 views
9 years ago

Hello I'm asking your help because I'm trying creating a Contact Form (using the example contcat form code in the Grav website) buy i have many problems:

  • I would like to add a "radio" or a "select" into the contact form, but everytime i try, and i save "frontmatter's invalid".
  • I would like to align all the contact form in the right side of the page, and add in the left side text or a bulletted list but i don't know how to do this

The code i'm using right now is this:

YAML
title: 'Sailpost Palermo'
form:
    name: contact-form
    fields:
-

pr_az:
type: radio
label: Privato o Azienda
default: privato
options:
privato: Privato
azienda: Azienda

name: cap
label: Dove
placeholder: 'CAP'
autofocus: 'on'
autocomplete: 'on'
type: text
validate:
required: true

YAML
            name: name
            label: Nome
            placeholder: 'Inserisci il tuo nome'
            autofocus: 'on'
            autocomplete: 'on'
            type: text
            validate:
                required: true
        -
            name: email
            label: Email
            placeholder: 'Inserisci il tuo indirizzo email'
            type: email
            validate:
                required: true

-
name: telefono
label: Telefono
placeholder: 'Inserisci il tuo numero di telefono'
autofocus: 'on'
autocomplete: 'on'
type: text
validate:
required: true

agree_to_terms: null
type: checkbox
label: 'Presto il consenso al trattamento dei miei dati personali, come da informativa sulla privacy Sailpost'
validate:
required: true
buttons:

YAML
            type: submit
            value: Submit
        -
            type: reset
            value: Reset
    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: 'Grazie per averci scritto, verrai contattato il prima possibile!'
        -
            display: thankyou

Thank you very much, sorry for bad english 🙂

9 years ago

If that truly is a paste of the form, then your problem is your lack of indentation. YAML is very picky about indentation as each sub-level must be indented at least 2 spaces, and it's best to keep those spaces consistent.

Also you appear to be mixing methods, the first field has the field name as the key, the second has the name: cap which is the old style.. It should look like this:

YAML
title: 'Sailpost Palermo'
form:
    name: contact-form
    fields:
        pr_az:
            type: radio
            label: Privato o Azienda
            default: privato
            options:
            privato: Privato
            azienda: Azienda
        cap:
            label: Dove
            placeholder: 'CAP'
            autofocus: 'on'
            autocomplete: 'on'
            type: text
            validate:
            required: true
        ...
👍 1

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago