Right now, you're only creating a Field. You could create a form API element (with hook_element_info()) that can be used by other forms, not just in Fields. The Field could then use that form API element and everybody would be so happy.

Comments

wesnick’s picture

I agree this would be nice to have. I think the element would be unwieldy, however, since it would require a huge number of properties, for example:

        '#separator' => ':',
        '#showLeadingZero' => FALSE,
        '#showMinutesLeadingZero' => TRUE,
        '#showPeriod' => TRUE,
        '#periodSeparator' => '',
        '#showHours' => TRUE,
        '#showMinutes' => TRUE,
        '#am_text' => 'AM',
        '#pm_text' => 'PM',
        '#minute_interval' => 5,
        '#showCloseButton' => FALSE,
        '#closeButtonText' => 'Done',
        '#showNowButton' => FALSE,
        '#nowButtonText' => 'Now',
        '#showDeselectButton' => FALSE,
        '#deselectButtonText' => 'Deselect',
        '#myPosition' => 'left top',
        '#atPosition' => 'left bottom',
rudiedirkx’s picture

That's fine, isn't it? Use good, sensible defaults. Most of those options never have to change. Whether to display a 24 or 12 hour clock would be the most used probably.

tien.xuan.vo’s picture

StatusFileSize
new12.21 KB

Here is the patch. I'm not good in form API and field API, so it just work.

This patch is for 1.0-alpha2.

Here is how to use it:

$form['my_timefield'] = array(
'#title' => t('Timefield'),
'#type' => 'timefield',
'#weight' => '0',
);

nicxvan’s picture

This patchworks!

nicxvan’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community
rv0’s picture

+1 for this functionality.

The project I need this sadly can't rely on a patched 3rd party module to work, so I'll roll my own time field for now.
But I'll considering switching if this code gets committed.

rcodina’s picture

Status: Reviewed & tested by the community » Needs work

Patch on #3 doesn't apply on latest dev version of module.