|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78584 Could you please populate $_FORMDATA?
Submitted: 2019-09-22 12:02 UTC Modified: 2019-09-22 12:09 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: 6562680 at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 7.2.23RC1 OS: Win10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: 6562680 at gmail dot com
New email:
PHP Version: OS:


 [2019-09-22 12:02 UTC] 6562680 at gmail dot com
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>
  <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>

// post.php

Expected result:
[ 'hello' => '123' ]

  ['hello[name][]', 123], // select(multiple)
  ['hello[name][]', 123], // input[]
  ['hello[name][]', 123], // input[]
  ['hello[]', 123], // input[]
  ['hello[]', 123], // input[]
  ['hello', 123], // input


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-22 12:09 UTC]
-Status: Open +Status: Suspended -Package: *Web Server problem +Package: *General Issues
 [2019-09-22 12:09 UTC]
A feature like this requires going through the RFC process.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jul 28 07:01:23 2021 UTC