Welcome Guest, Not a member yet? Register   Sign In
$this->input->post in ci4
#1

(This post was last modified: 09-05-2021, 09:00 AM by vohuuphuc.)

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
Reply
#2

(This post was last modified: 09-06-2021, 01:12 AM by InsiteFX.)

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'); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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
Reply
#4

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

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

(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 ^_^
Reply




Theme © iAndrew 2016 - Forum software by © MyBB