In Drupal 6, it was possible to set the granularity of a date field to 'minutes' but then leave time blank to allow for all day events. This functionality appears to be missing from Drupal 7. It's a pretty common use case. Is there a reason this functionality was removed?

Comments

harper1983’s picture

Subscribe

rv0’s picture

Subscribe

rv0’s picture

EDIT:

you can still add "all day" events by putting the time on 00:00

jastraat’s picture

Assuming that you aren't using a 12 hour time format - otherwise the user has to enter midnight.
Which isn't terribly user-friendly.

rv0’s picture

true, just to say the functionality is still in there...
i tried to add a checkbox for it with jquery, but somehow Date Popup interfered with my code.
so in my case, to make it user friendly, i did a form alter that changes the default value of the field to 00:00 if "to" date is empty (i.e. on new nodes)

it's not ideal, and i have to instruct the users that it means "all day"..

avdp’s picture

Do you have a code example perhaps?

rv0’s picture

@advp

you could put this in a custom module called custom_event

function custom_event_form_alter(&$form, &$form_state, $form_id) {
	if($form_id == 'events_node_form') {
		global $language;
		if(empty($form['field_event_date'][$language->language][0]['#default_value']['value2'])) {
			$form['field_event_date'][$language->language][0]['#default_value']['value'] = date('Y-m-d 00:00:00',time());
		}
		drupal_set_message(t('Events starting at 00:00 are "All Day" events'));
	}
} 

should work. (change the form_id to the id of your form)

avdp’s picture

@rv0
Thank you so much. I was on the right track but the details were wrong.

ohnobinki’s picture

+

karens’s picture

Status: Active » Closed (duplicate)

This is being discussed in #874322: To Date & All Day Date Handling.