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

Form names cannot be numbers

Open HunterDG opened this issue 4 years ago • 2 comments

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?

HunterDG avatar May 30 '20 00:05 HunterDG

its a yaml syntax issue, ive ran into it.

Yaml considers 1: as an array index 1 so it causes a lot of bugs

ricardo118 avatar May 31 '20 00:05 ricardo118

Also PHP has issues with numeric indexes. I would just not use numbers, but maybe prefix them with some letter.

mahagr avatar Jun 06 '20 07:06 mahagr