|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-09-22 12:09 UTC] requinix@php.net
-Status: Open
+Status: Suspended
-Package: *Web Server problem
+Package: *General Issues
[2019-09-22 12:09 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 07:00:01 2025 UTC |
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 ]