I have two date fields set up pretty identically. One has a 'todate' value (can indicate a duration) and the other does not. When I render the node creation form (and the field widgets) only the field with the 'todate' value actually gets it's label shown. I believe this label is supposed to show regardless.
I have identified a line in function date_combo_element_process($element, &$form_state, $form) that seems to resolve the issue, but I have no idea if this is a fix. (I removed the check to see if field has cardinality or is a repeat date, before displaying the label)
Here's the DIFF :
--- a/sites/all/modules/date/date/date_elements.inc
+++ b/sites/all/modules/date/date/date_elements.inc
@@ -289,7 +289,7 @@ function date_combo_element_process($element, &$form_state, $form) {
$element[$from_field] = array(
'#field' => $field,
- '#title' => (!$field['cardinality'] || $field['settings']['repeat']) ? t($instance['label']) : '',
+ '#title' => t($instance['label']),
'#weight' => $instance['widget']['weight'],
'#required' => ($instance['required'] && $delta == 0) ? 1 : 0,
'#default_value' => isset($element['#value'][$from_field]) ? $element['#value'][$from_field] : '',
Attached are a couple of screenshots to illustrate the before and after.
Is this a bug in the code (as I seem to see) or am I missing something in my config?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | date-missing-labels.patch | 1.06 KB | webchick |
| dates-with-labels | 23.16 KB | manimejia | |
| date-with-no-label | 21.57 KB | manimejia |
Comments
Comment #1
webchickConfirmed that I'm seeing this, too. Seems like a pretty bad bug, since it's breaking things (but doesn't render the module unusable like some of the fatal error issues do). Raising priority to "major".
I'm not 100% sure if that fix is correct (the code there is eerily specific about not wanting to show the title under most circumstances), but it seemed to solve my issue. Thanks a lot!
Here's manimejia's fix in patch form, so it can be more easily reviewed.
Comment #2
karens commentedThere was a reason for doing it this way, at least in D6, but I don't remember now what it was. Things are different in D7, the D6 behavior may not make sense any more, so we'll try it this way and see. Thanks!
Comment #4
george.plescan commentedI had the same bug.
You can't see the date field label which is very confusing.
The whole '#title' => t($instance['label']), part was missing in the file for some reason.