Closed KES777 closed 3 years ago
For this case it works fine:
<input name = "client[0][phone][]">
<input name = "client[0][phone][]">
<input name = "client[0][phone][]">
<input name = "client[0][email][]">
<input name = "client[0][email][]">
<input name = "client[1][phone][]">
<input name = "client[1][phone][]">
<input name = "client[1][email][]">
<input name = "client[1][email][]">
<input name = "client[1][email][]">
Also, probably, index and key usage on same level is semantic error, so warning also should be issued:
<input name = "client[name]">
<input name = "client[0][phone][]">
probably more correct way to write:
<input name = "client[name]">
<input name = "client[edrpou]">
<input name = "client[person][0][phone][]">
<input name = "client[person][0][phone][]">
<input name = "client[person][0][phone][]">
<input name = "client[person][0][email][]">
<input name = "client[person][0][email][]">
<input name = "client[person][1][phone][]">
<input name = "client[person][1][phone][]">
<input name = "client[person][1][email][]">
<input name = "client[person][1][email][]">
<input name = "client[person][1][email][]">
NOTICE: Here I add person
key
Thanks for report.
It is a bug. It's probably wrong in sematics, but not technically. Genrally, i go the same way as PHP does. I think PHP does a pretty good job of converting any form, doesn't matter how corrupt it is, to multidimensional array data.
This library should not be responsible for semantic warning. It is another topic.
So, case 1 will be fixed by fixing the auto increments internally.
For me
<input name = "client[name]">
<input name = "client[0][phone][]">
Is also valid. 0
as a key as any other, in Javascript and in any other programming language.
Only empty keys []
are handled specially.
So this example should return {"client":{"0":{"phone":[""]},"name":""}}
For sure, your second example is more correct
, if you need it like that.
I agree with case 2. No problem with:
<input name = "client[name]">
<input name = "client[0][phone][]">
Fixed Case 1 in 2.0.3beta
work as expected, thank you
Describe the bug
To Reproduce
Here I get 10 array elements as expected (green), also first
phone
is pushed into array as expected, but nextphone
(second, third) are objects firstemail
is array as expected, but nextemail
(second) is objectfor second,third email/phone I expect arrays
**probably this example is meaningless, because this is unusual to create
email
,phone
objects at separate array elements. They should be grouped together semantically. So for this case warning should be issued.**despite on unusual naming objects are not expected, e.g. counter should be flushed, when
[]
is processingTo my mind it should be just command to
push
into array and counter should not have matter. For cases when it has matter developer will use explicit value:[1]
or[7]
etc. (see post below)