Strange logic of CI Model with useCasts and validate for json-array field - 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: Strange logic of CI Model with useCasts and validate for json-array field (/showthread.php?tid=91741) |
Strange logic of CI Model with useCasts and validate for json-array field - Avega Soft - 09-29-2024 Hi everybody. I faced the following problem in CI 4.5.5. I use validation and casts on the CI Model side here is an example code: PHP Code: protected array $casts = [ When I try to insert data, a validation error occurs: profile.surname and profile.name - are required fields to fill in. After examining the BaseModel source code, I see that the transformDataToArray method casts profile values into a string and after that data validation occurs and, accordingly, an error occurs. As for me, the logic of the sequence of processes is strange. I understand that the validation method expects an array, but why casts it before that and is it a Bug or did I not understand the logic? |