Download & Extend

Wrong test for empty date field

Project:Drupal core
Version:6.x-dev
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

If no default value is given for the date field, it is supposed to default to today's date. However, expand_date() uses !isset() to determine whether a value has been given. Since the value is an empty string when not specified, this means the date field defaults to 1 January 1900. The attached patch fixes this by replacing !isset() with empty().

AttachmentSizeStatusTest resultOperations
form.inc-date.patch735 bytesIgnored: Check issue status.NoneNone

Comments

#1

If anyone would like to test this, I suggest trying the following code with and without the patch:

<?php
$form
['date'] = array(
 
'#type' => 'date'
);
$form = form_builder(NULL, $form);
$form = drupal_render($form);
echo
$form;
?>

#2

Status:needs review» reviewed & tested by the community

Yup.

#3

Version:5.x-dev» 6.x-dev

Committed to 5.

#4

Committed to CVS HEAD. Thanks.

#5

Status:reviewed & tested by the community» fixed

The Drupal 4.7 Form API works differently, so it doesn't require fixing.

#6

Status:fixed» closed (fixed)