How to swap fields in contact form

Hi, how I can swap fields in contact form. If I swap or add a new field, the form stops working.
Need swap Email with Phone fields

fields:
        -
            name: Name
            label: Iмя
            validate:
                required: true
                message: 'is required'
            autofocus: 'off'
            autocomplete: 'on'
            type: text
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            name: Email
            label: Email
            validate:
                required: true
                message: 'is required'
            type: email
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            phone: 'Телефон (whatsapp)'
            label: 'Телефон (whatsapp)'
            type: tel
            validate:
                required: true
                message: 'is required'
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            name: Message
            label: false
            placeholder: 'Ваше запитання...'
            validate:
                required: true
                message: 'is required'
            type: textarea
            outerclasses: 'col-6 col-12-small'
            classes: null
            rows: 7

Is this before or after? Could you share both? Also looks like indentation is a bit off

Before

---
title: Контакти
routable: false
cache_enable: false
form:
    name: contact-form
    template: form-messages
    action: /
    classes: 'row gtr-50 gtr-uniform'
    refresh_prevention: true
    fields:
        -
            name: Name
            label: Iмя
            validate:
                required: true
                message: 'is required'
            autofocus: 'off'
            autocomplete: 'on'
            type: text
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            name: Email
            label: Email
            validate:
                required: true
                message: 'is required'
            type: email
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            phone: 'Телефон (whatsapp)'
            label: 'Телефон (whatsapp)'
            type: tel
            validate:
                required: true
                message: 'is required'
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            name: Message
            label: false
            placeholder: 'Ваше запитання...'
            validate:
                required: true
                message: 'is required'
            type: textarea
            outerclasses: 'col-6 col-12-small'
            classes: null
            rows: 7
    buttons:
        -
            type: submit
            value: Відправити
            outerclasses: form-field
            classes: 'button primary'
    process:
        save:
            fileprefix: contact-
            dateformat: dmY-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
        email:
            subject: '[Form from Editorial Website] {{ form.value.name|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
        message: 'Thank you from your submission !'
        display: /thankyou
        reset: true
class: small
process:
    markdown: true
    twig: true
features:
    -
        icon: 'fa fa-phone'
        header: null
        text: +123-456-7890
        url: null
    -
        icon: 'fa fa-envelope'
        header: null
        text: hello@reallygreatsite.com
        url: null
    -
        icon: 'fa fa-home'
        header: null
        text: '123 Anywhere St., Any City'
        url: null
    -
        icon: 'fa fa-globe'
        header: null
        text: www.reallygreatsite.com
        url: null
---

After

---
title: Контакти
routable: false
cache_enable: false
form:
    name: contact-form
    template: form-messages
    action: /
    classes: 'row gtr-50 gtr-uniform'
    refresh_prevention: true
    fields:
        -
            name: Name
            label: Iмя
            validate:
                required: true
                message: 'is required'
            autofocus: 'off'
            autocomplete: 'on'
            type: text
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
            phone: 'Телефон (whatsapp)'
            label: 'Телефон (whatsapp)'
            type: tel
            validate:
                required: true
                message: 'is required'
            outerclasses: 'col-6 col-12-small'
            classes: null
        -
		    name: Email
            label: Email
            validate:
                required: true
                message: 'is required'
            type: email
            outerclasses: 'col-6 col-12-small'
            classes: null
		-	
            name: Message
            label: false
            placeholder: 'Ваше запитання...'
            validate:
                required: true
                message: 'is required'
            type: textarea
            outerclasses: 'col-6 col-12-small'
            classes: null
            rows: 7
    buttons:
        -
            type: submit
            value: Відправити
            outerclasses: form-field
            classes: 'button primary'
    process:
        save:
            fileprefix: contact-
            dateformat: dmY-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
        email:
            subject: '[Form from Editorial Website] {{ form.value.name|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
        message: 'Thank you from your submission !'
        display: /thankyou
        reset: true
class: small
process:
    markdown: true
    twig: true
features:
    -
        icon: 'fa fa-phone'
        header: null
        text: +123-456-7890
        url: null
    -
        icon: 'fa fa-envelope'
        header: null
        text: hello@reallygreatsite.com
        url: null
    -
        icon: 'fa fa-home'
        header: null
        text: '123 Anywhere St., Any City'
        url: null
    -
        icon: 'fa fa-globe'
        header: null
        text: www.reallygreatsite.com
        url: null
---


And what do you mean by “form stops working”?

It seems you’re missing the ‘name’ variable for the phone field

name: Phone
2 Likes

The form is no longer visible on the site.

BTW, I wonder how it works with the before config - your Phone field is missing the name :thinking:

Does it still save and send email?

Not yet, I work on localhost. But on local letters are not sent.

But it should save, or is save processor not working?

I am editing the contact.md file. I cut out the field with the phone and paste it in front of the field with the mail. And the form is not displayed on the site.

So far, I decided to rearrange the fields through the online editor for files .md type
But, every time turn to the online editor? Maybe there is another option? Syntax highlighting for files .md :thinking:

@NataliaB, You have been notified twice about a missing name property in the phone field. When are you trying to make that correction and report on it?

Yes, thanks, is this an error? Tell me please, now its correct?


            name: Phone
            label: 'Телефон (whatsapp)'
            type: tel
            validate:
                required: true
                message: 'is required'
            outerclasses: 'col-6 col-12-small'
            classes: null

@NataliaB, And try replacing all tabs with spaces…

Did you mean this tabs ?

 -

@NataliaB, I’m afraid I do not understand your last reply…

According the YAML specs:

To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently. Note that most modern editors may be configured so that pressing the tab key results in the insertion of an appropriate number of spaces.

@NataliaB, I see you have already opened a new post. Does that mean this issue has been solved? It is a good habit to mark a post as being solved by ticking the ‘solution icon’ in the lower right corner of the reply that has led you to the solution.

Please also reviews all your previous posts that have been solved.

1 Like