Unable to use validation rules that I set to the Config file - 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: Unable to use validation rules that I set to the Config file (/showthread.php?tid=77580) |
Unable to use validation rules that I set to the Config file - nileshsanyal - 09-20-2020 Hi, I am trying to perform form validation for user registration page with CodeIgniter 4. To do this I have written below codes in Validation.php file located in Config directory. Config/Validation.php PHP Code: public $userSignUp = [ Then I get this "userSignup" rule in my Users controller. Controllers/Users.php PHP Code: <?php namespace App\Controllers; Finally, to display those errors in the registration page. Views/user_register.php PHP Code: <?php if(isset($validation)): ?> But, when I submit the form, I get this error "userSignup is not a validation rules group". What is going wrong with my code? RE: Unable to use validation rules that I set to the Config file - InsiteFX - 09-20-2020 Did you place your config rules in the class? PHP Code: class Validation Also you using getRuleGroup where I believe it shoulld be setRuleGroup. RE: Unable to use validation rules that I set to the Config file - nileshsanyal - 09-21-2020 Hi @InsiteFX, finally I solved my problem, I misspelled "userSignUp" in the controller. Now, everything is working fine. RE: Unable to use validation rules that I set to the Config file - InsiteFX - 09-21-2020 Glad you got it working. |