Req #78584 [NEW]: Could you please populate $_FORMDATA?
| From: | 6562680 at gmail dot com | Date: | Sun, 22 Sep 2019 12:02:26 +0000 |
| Subject: | Req #78584 [NEW]: Could you please populate $_FORMDATA? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222862@lists.php.net to get a copy of this message | ||
From: 6562680 at gmail dot com
Operating system: Win10
PHP version: 7.2.23RC1
Package: *Web Server problem
Bug Type: Feature/Change Request
Bug description:Could you please populate $_FORMDATA?
Description:
------------
When PHP parses url with parse_str() to populate $_POST/$_FILES on
multipart/form-data,PHP merges same keys into one value, its known
behavior.
I tried to fill form fields after redirect from POST to GET with
validation error. When merged - it's not possible. Would be great to
have $_FORMDATA that should looks like this (opinion):
[
['hello[name][]', 123],
['hello[name][]', 123],
['hello[]', 123],
['hello[]', 123],
['hello', 123],
]
because $_POST will looks like [ 'hello' => 123 ]
Problem happened when we work with multifields (button '+ add field') or
multiselects - where we should set "selected" for its options
Test script:
---------------
// get.php
<form method="POST" type="multipart/form-data">
<select multiple="multiple" name="hello[name][]">
<option value="123">123</option>
</select>
<input type="text" name="hello[name][]" value="123" />
<input type="text" name="hello[name][]" value="123" />
<input type="text" name="hello[]" value="123" />
<input type="text" name="hello[]" value="123" />
<input type="text" name="hello" value="123" />
<button type="submit">Send</button>
</form>
// post.php
var_dump($_POST);
Expected result:
----------------
var_dump($_POST);
[ 'hello' => '123' ]
var_dump($_FORMDATA);
[
['hello[name][]', 123], // select(multiple)
['hello[name][]', 123], // input[]
['hello[name][]', 123], // input[]
['hello[]', 123], // input[]
['hello[]', 123], // input[]
['hello', 123], // input
]
--
Edit bug report at https://bugs.php.net/bug.php?id=78584&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78584&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78584&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78584&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78584&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78584&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78584&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78584&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78584&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78584&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78584&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78584&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78584&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78584&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78584&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78584&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78584&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78584&r=mysqlcfg