Community & Support

giving a date field a default value [solved]

$form['birthday']= array(
'#type' => 'date',
'#title' => t('Birthday'),
'#required' => $field->required,
'#default_value' => '02-03-2010',
);

I'm trying to give my date field a default value. This didn't work and I have tried a bunch of variations. Does anyone know the answer to this?

Comments

From memory it would

From memory it would be

'#default_value' => array('month' => 2, 'day' => 3, 'year' => 2010);

http://api.drupal.org/api/dru

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

Description: Format a date selection box. The #default_value will be today's date if no value is supplied. The format for the #default_value and the #return_value is an array with three elements with the keys: 'year', month', and 'day'. For example, array('year' => 2007, 'month' => 2, 'day' => 15)

Thanks you both

Thanks you both

Mike