Issue
If you create a date_popup time element (#date_format like 'H:i' or 'h:i:s', etc... i.e. no date field), the form value gets NULL'd when the form is submitted.

Cause
date_popup_validate() & date_popup_input_value() don't support date_popup form elements that contain just the time. They both require the date part. (See lines #311, #323, #368)

I could work on a patch for this, but I wanted to check if this was by design, a planned feature, or whether someone's already tackling it.

My use case
I have an event form & need the following from the user:
* Event Date
* Start time
* End time

I was trying to do this using two date_popup fields, with #format_date set to 'Y-m-d H:i' and 'H:i' respectively.

An alternative approach would be to set both #format_dates set to 'Y-m-d H:i', hide the date textbox for the 2nd field in the theme function, and extract just the time value on form submit, but that seems a bit of a hack.

What are your thoughts?

Would a patch to enable support for time_only date_popup fields be useful? Is there a different approach that I should explore? I'd be more than happy to work on a patch if you think that's the best way to go.

Comments

joostvdl’s picture

+1

karens’s picture

Category: bug » feature

The current code expects all the date elements to be complete dates and validates them that way, so this is a request to have different behavior, similar to other requests to have time-only CCK date fields.

The expectation that we're working with complete dates is pretty embedded into the code, so it will take some work to figure out how to allow times without dates in some cases but still do proper validation of dates where the missing date value is a mistake or error.

If anyone wants to tackle that, they can, but it's not a simple task.

arlinsandbulte’s picture

Status: Active » Closed (duplicate)