Closed (fixed)
Project:
Drupal core
Version:
x.y.z
Component:
forms system
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 May 2006 at 08:54 UTC
Updated:
14 Sep 2006 at 03:50 UTC
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
Comments
Comment #1
chromeyellow commented-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...
Comment #2
chromeyellow commented