Validate file if a select is... - 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: Validate file if a select is... (/showthread.php?tid=78836) |
Validate file if a select is... - pippuccio76 - 03-16-2021 i , sorry for english , i want validate a form with a select and file , only if select value is 6 the file must be uploaded . How can i create this rule ? this is my code: Code: <select id='id_id_stato_pratica' class="form-control border border-warning mxn-shadow-input mb-4" name='id_stato_pratiche' > This is my validation but don't work : Code: public function validate_pratica_completata(string $str,string $fields, array $data) RE: Validate file if a select is... - iRedds - 03-17-2021 If you upload a file, then information about it is in a separate array. Use a request instance instead of $data. PHP Code: $file = Config\Services::request()->getFile('field_name'); https://codeigniter.com/user_guide/libraries/uploaded_files.html RE: Validate file if a select is... - pippuccio76 - 03-17-2021 (03-17-2021, 02:16 AM)iRedds Wrote: If you upload a file, then information about it is in a separate array.how can i do this in validation? RE: Validate file if a select is... - kenjis - 03-17-2021 You can create custom validation rules. https://codeigniter4.github.io/CodeIgniter4/libraries/validation.html#creating-custom-rules RE: Validate file if a select is... - pippuccio76 - 03-18-2021 (03-17-2021, 05:21 PM)kenjis Wrote: You can create custom validation rules. The question is how can i pass file to validation ? I must control if a file is updated if select value is 6 |