Closed stevekr closed 8 years ago
Such request is not implemenatble: if DateValidator
will fill timestampAttribute
only if it is not set, it will be unable to update its value anyhow.
You should either use a scenarios to separate validation of user input and internal one or create a separated field some_date_source
, which should be used in user form and care the DateValidator
.
Maybe I have completely missed the point of timestampAttributeFormat
, but I see it as a way to ensure date fields are always in valid format for db (php:Y-m-d
). So if user submits form with date in dd.MM.yyyy
format, it gets converted and all is good. If date is loaded from db and is already in valid php:Y-m-d
format, then it should not give validation errors. So it seems logical that DateValidator
uses both format
and timestampAttributeFormat
for validation.
This issue may be also fixed if validation is triggered only on dirty attributes #8610
I suppose this could be implemented.
Thanks :thumbsup:
Resolved by commit 779b1e90cea13ca3a05768a8e82b96b022d1f710
I have form field in custom date format that is converted to mysql format:
Saving with form works great, but if I need to update some other field without using form and try to validate, it gives me an invalid format error, because
some_date
is not converted todd.MM.yyyy
format and is still inphp:Y-m-d
. So attributes inDateValidator::$timestampAttributeFormat
format should also be valid.