Form - Array To String Conversion Error

Hello,

Playing around trying to get a form running within my Grav setup, but I’m getting an error (there is info and some solutions on the forum but the coding side is a little past my understanding/capability).

The page is at:

The issue is something to do with the pulldown element - if I omit this from the form, everything works as intended and I get to my makeshift Thank You page. I can’t think of another way to exercise these options on the form (other than checkboxes but can only have the user be able to select one, not multiple) so it’d be nice to try and get to the bottom of why the pulldown selection is causing this error.

Many thanks.

1 Like

Please share the Twig-template that throws the error, as it looks when the error appears. The error is basically saying that you are trying to output the list of data directly, without looping over it.

1 Like

I have the same error.

"An exception has been thrown during the rendering of a template ("Array to string conversion")."

My forms config:

---
title: Contact
form:
    name: contact
    fields:

        location:
            type: select
            label: 'Select your city'
            multiple: false
            options:
                test1:
                    value: 'test1'
                test2:
                    value: 'test2'
                test3:
                    value: 'test3'
                    disabled: true
            validate:
                required: true
                message: 'Select your city'

    buttons:
        submit:
            type: submit
            value: Send
        reset:
            type: reset
            value: Reset

    process:
        email:
            subject: '[Contact form] {{ form.value.name|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
        save:
            fileprefix: contact-
            dateformat: Ymd-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
        message: 'Thank you for your message!'
        display: thankyou

process:
    markdown: true
    twig: true
---

Any way to solve this?

It seems to go wrong here: {{ field.options[value]|t|e }} in /user/plugins/form/templates/forms/default/data.html.twig line 44. I don’t use multiple , so it shouldn’t be of type array, right?

More info in the docs: Reference: Form Field Index | Grav Documentation