It would be useful if the date element (e.g. $form['date_example'] = array('#type' => 'date', '#title' => t('Start date')) ) also passed a timestamp, to be used by modules that need some basic validation (i.e., is date set in the past, is it set at all, etc).

I posted my reasoning and a possible patch in the dev forum, before thinking it should be here. Read more at

http://drupal.org/node/61580

Comments

chromeyellow’s picture

Status: Active » Postponed

-1 from me, the one suggesting this...

It's obvious that the timestamp can be recalculated for validation purposes in a validation function. Part of the reasoning for passing it with the form - a reason which I neglect to mention in the long forum post mentioned above - is that by doing so we avoid 3 more calls to format_date. I figured that, since the drupal native #date form element is already doing the work, there's no reason to do it again in the event that date validation is needed.

But calculating the timestamp in advance does add one call to format_date - every time, whether needed (which is unlikely, I grant) or not. So on balance it ain't worth it.

What is worth it would be a form api validation function snippets section...

chromeyellow’s picture

Status: Postponed » Closed (fixed)