Just a vague pondering which I don't have time to work on... ;)
Currently this only works on CCK date fields. But the changes we make to the date field are actually made to the date form element -- adding a #theme and an #after_build callback.
It might be possible to do this to any date form element, using the same technique as in http://drupal.org/project/checkbox_validate -- that redeclares (I think!) the checkboxes element to have a different #process callback.
If this were possible, then our own #process callback would check for a custom key, say, #single_day, and act on that.
Meanwhile, the CCK side of things in date_single_day_form_alter() would just set #single_day for the processing to find.
The upshot would be that nothing changes... ;) but a custom module that uses a date element in its own form could also request it to have a single day by setting #single_day in the form array.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1128194.date_single_day.hook-elements.patch | 2.87 KB | joachim |
Comments
Comment #1
damienmckennaDuplicate of #812262: Use for other (non-popup) date fields?.
Comment #2
damienmckennaWait, no, that's not strictly a duplicate. #facepalm
Comment #3
joachim commentedI've got this working but I'm not convinced.
It adds a fair amount of code, and I'm not sure there's much gain. The only Form API element where this makes sense is date_combo, which is defined in CCK Date module anyway.
Here's the patch while I ponder it.
Comment #4
anjjriit commentedHow to theme my date form element ?
i have tried //'#theme' => array('date_single_day_element'), ---> but did not worked
Thanks