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

Form - Array To String Conversion Error

Started by Nimesh 4 years ago · 2 replies · 785 views
4 years ago

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:

https://cueballpromotions.co.uk/event-entry-form

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
4 years ago

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
3 years ago

I have the same error.

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

My forms config:

YAML
---
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: https://learn.getgrav.org/17/forms/forms/fields-available#section-field

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 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 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago