grav-plugin-form icon indicating copy to clipboard operation
grav-plugin-form copied to clipboard

error/warning when submitting a form with recaptcha

Open manuel-84 opened this issue 7 years ago • 4 comments
trafficstars

plugin v2.11.1 - Grav v1.3.10

/user/plugins/form/classes/form.php : 628 (E_WARNING): "key() expects parameter 1 to be array, string given"

$action = \key($data); arguments: "captcha"

my form:

form:
    name: contatto
    fields:
        -
            name: nome
            label: 'Nome e Cognome'
            placeholder: 'Nome e Cognome'
            autocomplete: 'on'
            type: text
            validate:
                required: true
        -
            name: email
            label: 'Indirizzo E-Mail'
            placeholder: 'Indirizzo E-Mail'
            type: email
            validate:
                required: true
        -
            name: messaggio
            label: Messaggio
            placeholder: Messaggio
            type: textarea
            validate:
                required: true
        -
            name: g-recaptcha-response
            type: captcha
            label: 'Verifica antispam'
            recaptcha_not_validated: 'Captcha non valida!'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Invia
    process:
        - captcha
        -
            email:
                subject: '[Email di contatto da XXX] {{ form.value.nome|e }}'
                body: '{% include ''forms/data.html.twig'' %}'
        -
            save:
                fileprefix: contatto-
                dateformat: d-m-Y-H.i.s-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %}'
        -
            message: 'Grazie per averci contattato!'
        -
            display: thankyou

manuel-84 avatar Jan 15 '18 15:01 manuel-84

as a workaround you can add this line of code before if (is_numeric($action)) {:

if (!is_array($data)) continue;

manuel-84 avatar Jan 15 '18 16:01 manuel-84

there have been some releases since I've opened this issue but it is still unfixed

manuel-84 avatar Feb 19 '18 11:02 manuel-84

Having the naked 'captcha' in the process section seems to be the issue. Here is my fix:

    process:
        - captcha:
            dummy: dummy

k8n avatar Aug 23 '18 19:08 k8n

Same issue suddenly (Grav 1.7.23, Form v5.1.2).

workaround suggested seems to be working as well.

I have added if (!is_array($data)) continue; in user/plugins/form/classes/Form.php line 925

xaa avatar Oct 14 '21 19:10 xaa