Date popup default value doesn't work. Default value must be in format 'Y-m-d H:i:s' (more on #509036: Default date and date popup in a custom module).
Also, in balance_tracker.module I think that code:
$form['date_from'] = array(
'#type' => 'date_popup',
'#title' => t('From'),
'#default_value' => date($format, $user->created),
'#date_format' => $format,
'#date_label_position' => 'within',
'#date_timezone' => 'America/Chicago',
'#date_increment' => 15,
'#date_year_range' => '-3:+3',
);
$form['date_to'] = array(
'#type' => 'date_popup',
'#title' => t('To'),
'#default_value' => date($format, $_SERVER['REQUEST_TIME']),
'#date_format' => $format,
'#date_label_position' => 'within',
'#date_timezone' => 'America/Chicago',
'#date_increment' => 15,
'#date_year_range' => '-3:+3',
);
should be
$form['date_from'] = array(
'#type' => 'date_popup',
'#title' => t('From'),
'#default_value' => date('Y-m-d H:i:s', $from),
'#date_format' => $format,
'#date_label_position' => 'within',
'#date_timezone' => 'America/Chicago',
'#date_increment' => 15,
'#date_year_range' => '-3:+3',
);
$form['date_to'] = array(
'#type' => 'date_popup',
'#title' => t('To'),
'#default_value' => date('Y-m-d H:i:s', $to),
'#date_format' => $format,
'#date_label_position' => 'within',
'#date_timezone' => 'America/Chicago',
'#date_increment' => 15,
'#date_year_range' => '-3:+3',
);
I has changed $user->created to $form variable, and $_SERVER['REQUEST_TIME'] to $to variable.
Comments
Comment #1
brianV commentedFixed in D6 dev:
http://drupal.org/cvs?commit=477860
Comment #3
asad.hasan commentedVery helpful post. Thank you.
Comment #4
netake.nilesh commentedVery helpful thanks.