Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using the date_select element in a form definition without a #default_value, an undefined index warning is produced:
'Notice: Undefined index: #default_value in date_select_element_process() (line 462 of /sites/all/modules/contrib/date/date_api/date_api_elements.inc)
Sample code:
$form['subscribe']['date'] = array(
'#type' => 'date_select',
'#title' => t('Date'),
'#date_format' => 'F-d-Y',
'#date_year_range' => '0:+1',
'#date_label_position' => 'within',
'#validated' => TRUE,
);
Comment | File | Size | Author |
---|---|---|---|
#6 | date_api_elements-2204713-6.patch | 623 bytes | jstoller |
| |||
#5 | interdiff-2204713-4-5.txt | 1.36 KB | BR0kEN |
#5 | date_api-undefined-index-in-date_select_element_process-2204713-5.patch | 2.16 KB | BR0kEN |
Comments
Comment #1
ebeyrent CreditAttribution: ebeyrent commentedHere's a patch.
Comment #2
gaurav.goyal CreditAttribution: gaurav.goyal commentedThis bug was also there in the Date 7.x-2.6 Version, Above patch #1 solves the problem. But there was an error in apply the patch
Just added a little to it, now it can be applied, attached is the patch.
Comment #3
BR0kENComment #4
BR0kENComment #5
BR0kENOops, forgot some changes. Ignore previous patch.
Comment #6
jstollerThe patch in #2 fixes the problem, but doesn't apply properly since the paths are off. The attached patch will apply from the module's root directory.
The patch in #5 seems to work as well, but it makes a bunch of apparently unrelated changes with no explanation, so I'm avoiding it for now.
Comment #7
jstollerI've been using this for two years now, so seems safe to commit.
Comment #9
DamienMcKennaCommitted. Thanks.