grav-plugin-form
grav-plugin-form copied to clipboard
error/warning when submitting a form with recaptcha
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
as a workaround you can add this line of code before if (is_numeric($action)) {:
if (!is_array($data)) continue;
there have been some releases since I've opened this issue but it is still unfixed
Having the naked 'captcha' in the process section seems to be the issue. Here is my fix:
process:
- captcha:
dummy: dummy
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