CodeIgniter Forums
Validate is changing the integer keys of my post data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Validate is changing the integer keys of my post data (/showthread.php?tid=89205)



Validate is changing the integer keys of my post data - enthuast - 01-22-2024

I don't really know how to explain this well, but basically:
Original post data:
PHP Code:
[
  "17" => "a",
  "18" => "b",
  "normal" => "c",


After validating (retrieved using validator->getValidated())

PHP Code:
[
  "0" => "a",
  "1" => "b",
  "normal" => "c",


As you can see, string keys are fine even after validation, but integer keys gets changed.
Why does it do this, and how do I preserve my original keys? (Right now, I'm just adding a prefix "_" to every keys, but I wonder if there's a better way)



RE: Validate is changing the integer keys of my post data - kenjis - 01-22-2024

This bug?
https://github.com/codeigniter4/CodeIgniter4/pull/8425


RE: Validate is changing the integer keys of my post data - enthuast - 01-23-2024

(01-22-2024, 10:08 PM)kenjis Wrote: This bug?
https://github.com/codeigniter4/CodeIgniter4/pull/8425

Oh wow, that's exactly it. So it was a bug after all.
I tried using the command "composer update", but it didn't do anything, so I assume I'm going to have to change it myself and wait for an update.
Thanks for the help though!


RE: Validate is changing the integer keys of my post data - kenjis - 01-23-2024

Yes, the bug fix will be included in v4.4.5.