yiisoft/yii — pull request #2312 by joni (2013-04-07 18:33:44+00:00)
Title: Set timestampAttribute to null when CDateValidator allows empty

Resubmit of https://github.com/yiisoft/yii/pull/806: "By the documentation, `timestampAttribute` should get set when the date is valid. If the validator is set to allow empty values, it's logical that `timestampAttribute` should be set to null when the original attribute is empty."

I find the alternative that is suggested - setting a default value with `CDefaultValidator` - unacceptably brittle because you have to use *two* validation rules that *have to be in this particular order*:

array('start_date', 'default', 'value'=>null, 'setOnEmpty'=>false),
array('start_date_str', 'date', 'format'=>'d/M/yyyy', 'timestampAttribute'=>'start_date'),