If ran separately, it even saves the data to the db. BUT, when I run validate() first and then try to save(), it gives me false and the correct error message without saving to the database. What is going on? I’m not encountering any problems with other validators (string, required etc.)
$model->validate();$model->save(); -->> false and prevents saving to the db
The code is a little bit more complicated of course, I’m checking the value in the “if” condition, though I tried to check its value by dumping and echoing it as well. Same result. If I run save() without running validate() first, it saves to the database in spite of wrong data, as if the validator never runs. When I run validate() first, suddenly save() returns the error (not the validate() though). I’m not overloading the validate or save methods at all, so I’m really puzzled what’s happening here.
I’ll probably try to create an isolated test project to see if it behaves the same way (and post here as an executable example for others to test) when I have more time, but in the meantime I’d like to know if someone else encountered such weird problem.