CodeIgniter Forums
$this->input->post in ci4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: $this->input->post in ci4 (/showthread.php?tid=80036)



$this->input->post in ci4 - vohuuphuc - 09-05-2021

Hi everyone,

I have a problem in ci4
i don't know how to get array in ci4

Code:
<input class="priority" type="text" name="priority[]" value="a">
<input class="priority" type="text" name="priority[]" value="b">
<input class="priority" type="text" name="priority[]" value="c">
i want to get array of value like : $priority = array([0] =>"a", [1] => "b", [2] = "c");

Please help me  Cry


RE: $this->input->post in ci4 - InsiteFX - 09-06-2021

This is how its done in ci 4.

PHP Code:
$request = \Config\Services::request();

// leave PropertyName blank to get all properties.
$data = $request->getPost('PropertyName'); 



RE: $this->input->post in ci4 - vohuuphuc - 09-06-2021

(09-06-2021, 01:11 AM)InsiteFX Wrote: This is how its done in ci 4.

PHP Code:
$request = \Config\Services::request();

// leave PropertyName blank to get all properties.
$data = $request->getPost('PropertyName'); 

Code:
$request = \Config\Services::request();
$priority_array = $request->getPost('priority');
$id_array = $request->getPost('id');
$temp = array_combine($id_array, $priority_array);
print_r($temp);

Thank for your helping .User Guide made me confused  Big Grin


RE: $this->input->post in ci4 - ikesela - 09-06-2021

If in controller, u can just call like this":

$priority = $this->request->getPost('priority');


RE: $this->input->post in ci4 - vohuuphuc - 09-07-2021

(09-06-2021, 11:15 AM)ikesela Wrote: If in controller, u can just call like this":

$priority = $this->request->getPost('priority');

it work fine. thank you so much ^_^