Form validation checkbox doesn't work |
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.*' => [
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() |
Welcome Guest, Not a member yet? Register Sign In |