grav-plugin-form
grav-plugin-form copied to clipboard
RuntimeError when using checkbox, spacer or honeypot fields under PHP 7.4
I get the following RuntimeError when using checkbox, spacer or honeypot fields under PHP 7.4. Under PHP 7.3 everything works as expected without errors.
An exception has been thrown during the rendering of a template
("Trying to access array offset on value of type int").
.../user/plugins/form/templates/forms/default/field.html.twig9
The definition of the affected fields is done on a modular page and looks as follows:
- agree_to_terms:
type: checkbox
validate:
required: true
outerclasses: privacy-checkbox
- agree_to_terms_text:
type: spacer
text: Ich habe die Datenschutzerklärung gelesen und bin einverstanden *
- honeypot:
type: honeypot
Issue exist on:
- Grav v1.6.28
- Form v4.1.2
- PHP 7.4
Any ideas on how to solve this issue?
Are you on the latest released version of Form plugin? I can run fine under PHP 7.4, even PHP 7.8 with checkbox and radio fields. I'll have to get a test page with your blueprint elements though (although they look fine).
Thank you for the quick reply. Yes, the version is v4.1.2. I also tried to delete the plugin and reinstall it. In my case just one of the fields is enough to produce the error. Text inputs and textareas are working fine. Should I copy the whole form definition here?
Try writing the form in this format:
agree_to_terms:
type: checkbox
validate:
required: true
outerclasses: privacy-checkbox
agree_to_terms_text:
type: spacer
text: Ich habe die Datenschutzerklärung gelesen und bin einverstanden *
honeypot:
type: honeypot
So basically remove dash from the form fields, it's not supported.
PS: Dash format works without the key like this:
-
name: agree_to_terms
type: checkbox
validate:
required: true
outerclasses: privacy-checkbox
-
name: agree_to_terms_text
type: spacer
text: Ich habe die Datenschutzerklärung gelesen und bin einverstanden *
-
name: honeypot
type: honeypot
Thanks a lot, now it works! 🎉😊
I got the template for the (not supported) formatting from the link "Page markdown file" on the Grav documentation page: https://learn.getgrav.org/16/forms/forms/example-form
@rhukster It looks like some of the skeletons have bad blueprint markup:
https://raw.githubusercontent.com/getgrav/grav-skeleton-soraarticle-blog/develop/pages/03.contact/form.md
That format has never been supported, so likely the form has never been properly validated.
I'm reopening this issue, CC @rhukster
Should we fix those skeletons?