![]() |
Filters and $_POST (or $request post vars) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Filters and $_POST (or $request post vars) (/showthread.php?tid=79791) |
Filters and $_POST (or $request post vars) - Kaosweaver - 07-27-2021 I want to automatically add variables to each incoming POST, so I thought filters would be helpful, however, I can't see a way to get to the POST vars in the filter class PHP Code: class Filters extends BaseConfig the PostFilters class: PHP Code: class PostFilter implements FilterInterface I've also tried: PHP Code: public function before(RequestInterface $request, $arguments = null) PHP Code: public function before(RequestInterface $request, $arguments = null) It is adding the varaibles to the RequestInterface $request (from log_messages, I see this). Even the direct $_POST didn't add it to the post vars in the controller. Where should I be doing this (or how do I make the filters see the $_POST vars and add to them)? Thanks. RE: Filters and $_POST (or $request post vars) - Gary - 07-29-2021 Try using $_REQUEST['Maint_Userid']... or whatever the form/post variable's name it is you want to access from inside the Filter. Code: public function before(RequestInterface $request, $arguments = null) RE: Filters and $_POST (or $request post vars) - Kaosweaver - 08-02-2021 (07-29-2021, 02:19 PM)Gary Wrote: Try using $_REQUEST['Maint_Userid']... or whatever the form/post variable's name it is you want to access from inside the Filter. That would get me the values in the POST. I'm looking to *add* values to the POST for processing (as in, for each POST, I want to add the user's ID for both the create and maint fields) RE: Filters and $_POST (or $request post vars) - paliz - 08-02-2021 [quote pid="389059" dateline="1627911401"] you need api ctl other ctl extend from it after log in call $userId [/quote] you dont need add data to post request PHP Code: <?php RE: Filters and $_POST (or $request post vars) - Kaosweaver - 08-10-2021 Actually, I've sorted out the issue that I needed to sort out. I really didn't need the vars as part of the POST, I needed them to be automatically filled in when I submitted my records for insert or update to the database, so, the database beforeInsert and beforeUpdate fixed the issue (in the model): PHP Code: namespace App\Models; |