Contact Form and many questions

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:

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
-
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:
-
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 :slight_smile:

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:

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 Like