grav-plugin-form
grav-plugin-form copied to clipboard
Form names cannot be numbers
Goal: submitted form returns saved values in numerical order like:
Name: hunterdg
1: answer to Q1
2: answer to Q2
Originally I struggled to create simple numbered form fields at all due to ("Trying to access array offset on value of type int")
.
fields:
- name: 1
- name: '2'
I found that prefixing numbers with .
works for rendering, but nut for submitted form data
fields:
- name: Name
- name: '.1'
- name: '.2'
- name: ' 3'
- name: ' 4'
returns
Name: hunterdg
.1: null
.2: null
3: 3
4: 4
(3 and 4 are prefixed with spaces)
Is this a bug or should I work around it?
its a yaml syntax issue, ive ran into it.
Yaml considers 1:
as an array index 1 so it causes a lot of bugs
Also PHP has issues with numeric indexes. I would just not use numbers, but maybe prefix them with some letter.