Welcome Guest, Not a member yet? Register   Sign In
Add a new function to add to request methods (POST, GET etc)
#1

Hi,
I'm not sure if the functionality for this already exists as I haven't been able to find any documentation for this in the CI docs. Basically we should be able to add to a GET or POST request vars manually using a method like
PHP Code:
$this->request->setPost('key' => 'value'); 

Currently if you need to add something to a request inside a controller, then you set it like so
PHP Code:
$_POST['key'] = 'value'
And then if you try to use
PHP Code:
$this-request->getPost(); 
the newly added key - value pair doesn't appear in that method.
Reply
#2

It's not super clear in the doc, but what you're looking for is setGlobal:
PHP Code:
$this->request->setGlobal('post', [
    'foo' => 'bar',
    'bar' => 'baz',
]); 
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(07-06-2022, 01:40 PM)includebeer Wrote: It's not super clear in the doc, but what you're looking for is setGlobal:
PHP Code:
$this->request->setGlobal('post', [
    'foo' => 'bar',
    'bar' => 'baz',
]); 
Yes I saw that, but that overwrites the values of all other $_POST variables.
Reply
#4

> Basically we should be able to add to a GET or POST request vars manually

Why do you need such a functionality?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB