![]() |
custom validation rule fails - 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: custom validation rule fails (/showthread.php?tid=88072) |
custom validation rule fails - sjender - 07-14-2023 Hi all, I have this strange behaviour in my custom validation rule. In my model I have this validation: PHP Code: protected $validationRules = [ You can see I use 2 variables: parent_id and id. In my controller I run: PHP Code: $category = $this->categoriesModel->find($categoryId); Code: [attributes:protected] => Array But my validation rule doesn't recognize the parent_id... PHP Code: SELECT * As you can see it recognizes the {id}, but not the {parent_id}. When I add $category->parent_id = 123; it works, but parent_id is already present in the $category entity, I don't want to explicitly set this value... RE: custom validation rule fails - sjender - 08-08-2023 I think I already know why this is failing.... Can this be the case because the validator only has access to the primary key and CHANGED values? In this case the PARENT_ID is not changed, so it might not be available in my custom rule? Is there a way to force an update on ALL fields, even when they're not changed? RE: custom validation rule fails - sammyskills - 08-08-2023 Where is the code for the custom validation rule? RE: custom validation rule fails - sjender - 08-13-2023 I have placed it in \Custom\CustomValidationRules.php And added that class in The validation config as well RE: custom validation rule fails - sammyskills - 08-13-2023 Show/paste the code here. |