![]() |
How to restrict hidden input field in save() method. - 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: How to restrict hidden input field in save() method. (/showthread.php?tid=89006) |
How to restrict hidden input field in save() method. - sknair143 - 12-20-2023 Hello Everyone, I have a from where i get some inputs from the user, i use same for for create and edit. In edit case i need to use hidden input field for some id reference purpose. But when i save using the save() method the hidden input field also passing into the database that gives me error. Form : Code: <div class="mb-3 col-md-3"> Method : PHP Code: if($this->request->getPost() ) { How i can restrict the hidden fields passed into the save() method ? RE: How to restrict hidden input field in save() method. - kenjis - 12-20-2023 See https://codeigniter4.github.io/CodeIgniter4/libraries/validation.html#the-controller RE: How to restrict hidden input field in save() method. - sknair143 - 12-20-2023 @kenjis Thanks for your reply. Can you give a example. I'm new to codeigninter. RE: How to restrict hidden input field in save() method. - kenjis - 12-20-2023 1. You can specify an array of field names like $this->request->getPost(['field1', 'field2']). 2. It is better to validate all user input data. RE: How to restrict hidden input field in save() method. - sknair143 - 12-20-2023 (12-20-2023, 12:54 AM)kenjis Wrote: 1. You can specify an array of field names like $this->request->getPost(['field1', 'field2']). @kenjis So here i can exclude those hidden input fields right ? RE: How to restrict hidden input field in save() method. - kenjis - 12-20-2023 Yes, if you pass an array with required fields to $this->request->getPost(). |