Strange logic of CI Model with useCasts and validate for json-array field |
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? |
Welcome Guest, Not a member yet? Register Sign In |