Form validation checkbox doesn't work - 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: Form validation checkbox doesn't work (/showthread.php?tid=77944) |
Form validation checkbox doesn't work - gbwebapps - 11-08-2020 Hello there. I have a form with some checkboxes. These checkboxes are not mandatory. They work fine with is_exist rule. This scenario works fine. Checkboxes: Code: <input class="form-check-input" type="checkbox" name="users_permissions[]" value="add_brands"> Rules Code: 'users_permissions[]' => [ When I send data, all is working fine. But if I intentionally put a number as a checkbox value like this... Code: <input class="form-check-input" type="checkbox" name="users_permissions[]" value="1"> ...having alpha_dash as a rule, I should receive an error which not occur. The same if I upside down the situation like this: Checkboxes Code: <input class="form-check-input" type="checkbox" name="users_permissions[]" value="add_brands"> Rules Code: 'users_permissions[]' => [ I don't get any error. The form is regularly sent. Where am I wrong with checkboxes validation? OK, I've just read a topic of yesterday and I read the guide in at this point: Validating keys that are arrays So, I'm trying this solution.: Instead of Code: 'users_permissions[]' => [ I put now this Code: 'users_permissions.*' => [ But I don't get error messages anyway. Some advices? Thanks Also tryng this way: Code: 'users_permissions.*' => [ RE: Form validation checkbox doesn't work - gbwebapps - 11-08-2020 Just a little piece of update. I have this problem when I call getError(), for the single validation This one doesn't return the array errors Code: $this->validator->getError('checkboxes') This one returns the array errors Code: $this->validator->listErrors() |