I’m new at this and probably doing something wrong, but when you use the CDateValidator class, it won’t validate an “empty” MySQL date value of ‘0000-00-00’. I want to do this because I have an optional date field (birthday.)
I’ve figured out how to blank out the default date value, so that nothing shows in the view or update form, and if you don’t enter a date, it will save as ‘0000-00-00’. (I had to substitute an empty validator function to get by the validation step to actually enter a blank field. But now of course illegal data will crash the program, so I realize I need some sort of validation.)
Should I write my own custom date validator, or is there a way to feed the standard CDateValidator class to do what I want?
Here is the code from the Profile.php model of the User Module:
Yeah I read all the documentation. I guess my point was that the validator only accepts NULL or ‘’ as “empty,” whereas there is no such thing as a truly empty date–it’s ‘0000-00-00’. I was hung up on getting the validator to accept the default “empty” date string, instead of giving the validator what it wants, then giving MySQL what IT wants afterward.