Wednesday, October 5, 2011

Partial date validation / Model::deconstruct() thoughts

I've been digging into date validation and I think I understand it
pretty well, but it's a bit frustrating.

Scenario:
There is a Period Start date and a Period End Date. They are optional,
but if the Period Start is entered, then the Period End must be
entered and must be after the Period Start.

The Issue:
If you select an incomplete date (e.g. Month, Day, but no Year), due
to the way Model::deconstruct builds the date string, an empty string
is returned. Thus there is no way to give a user-friendly warning that
it appears they forgot the year in the date.

Additionally, the selected values are not retained if a partial date
is entered.

How I think it should work:
There should be a way to get the "raw" date array values into a custom
validation method so that I can set up a custom validation method for
partial dates. I want to set up a message saying "Please verify the
date or leave the fields blank" and display the form again with their
partial date values selected.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: