The code which generates the various options for the jQuery Timepicker assumes that there is a default value set:

// The first value in the dropdown list should be the same as the element
// default_value, but it needs to be in JS format (i.e. milliseconds since
// the epoch).
$start_time = new DateObject($element['#default_value'], $element['#date_timezone'], DATE_FORMAT_DATETIME);

I do not want to supply a default value for my custom field and I get the following error: Notice: Undefined index: #default_value in date_popup_process_time_part() (line 406 of date/date_popup/date_popup.module).

I'm not sure whether my solution is the best option, but I added a new attribute to the element array called #start_time and I have altered the above code to:

if (isset($element['#start_time'])) {
  $time = $element['#start_time'];
}
elseif (isset($element['#default_value'])) {
  $time = $element['#default_value'];
}
else {
  $time = 'now';
}
$start_time = new DateObject($time, $element['#date_timezone'], DATE_FORMAT_DATETIME);

Comments

intrafusion’s picture

Status: Active » Closed (works as designed)

OK everything is working fine, I should have added:

'#default_value' => '',