Create Model with command line |
Hi..
I created model from command line and when i open the model file to edit there is this part which i don't understand. PHP Code: protected $cleanValidationRules = true; Can anyone give explanation or point out the documentation on what is it and how to use that part? I've tried search on the userguide but found nothing, or maybe i wasn't looking carefully because i only use the search input with cleanValidationRules text.
09-25-2022, 12:37 AM
(This post was last modified: 09-26-2022, 01:00 AM by InsiteFX. Edit Reason: Spelling error got new keyboard now. )
I had to look at the system/BaseModel to find it.
PHP Code: /** What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
It seems the functionality is not documented.
See the source code. https://github.com/codeigniter4/CodeIgni....php#L1340
Thanks @kenjis , @InsiteFX
So looking at your pointers does it means that if set to true then whenever we pass request data on model for easy to insert/update it will only validate only matching field/rules name on request data? Does it also works not only on model but on every time we use validation library? I was thinking if i can make that some global validation that have all rules saved on validation config or separate files. Sorry for my bad english.
If $cleanValidationRules is true, the validation rules for the field that is not contained in the passed data will be removed before validation.
But it does not seems to work if you don't call validate() by yourself. If you call insert() or update() or save(), the $cleanValidationRules value will be changed automatically. I'm not sure this is a bug or not. Anyway, it is a feature in Model, not in the Validation library.
(09-25-2022, 02:20 PM)kenjis Wrote: If $cleanValidationRules is true, the validation rules for the field that is not contained in the passed data will be removed before validation.Yes, i think it is a bug too. I tried and get the same result also. There would be no use to put $cleanValidationRules in model if it gets replaced automatically on calling model insert/update/save. The only way it would works if we capture the validation error on validate() then stop executing next line. Is there any other workaround? (09-25-2022, 08:23 PM)[email protected] Wrote: Yes, i think it is a bug too. I tried and get the same result also. There would be no use to put $cleanValidationRules in model if it gets replaced automatically on calling model insert/update/save. Agreed. Okay, I will fix it as a bug.
|
Welcome Guest, Not a member yet? Register Sign In |