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.
Conditions:
Create a date field and make it render as regular field (using the checkbox provided in the advanced settings). On "date attributes to collect", only choose year.
Result: The field is rendered without a label.
If you either choose to render as fieldset (clearing checkbox to render as regular field), or if you add month to the data attributes to collect, the label shows fine.
I don't think I had this problem with 2.8 version, so I suppose this bug was introduced in 2.9.
Comment | File | Size | Author |
---|---|---|---|
#12 | date-n2595957-12.patch | 1.01 KB | DamienMcKenna |
| |||
#12 | date-n2595957-12.interdiff.txt | 1.07 KB | DamienMcKenna |
Comments
Comment #2
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedI also met this issue.
The field label is not displayed when we use only year-month-date. After researching it, I found that this bug occurs only with the widget type `date_popup`. Other widget types in date module such as `date_text` and `date_select` don't have this issue at least in my environment.
The steps to reproduce the bug:
1. Install and enable the date and date_popup modules.
2. Create a field with date type for a content type.
3. Configure the settings for the field as following:
- Check only Year, Month and Day in "Date attributes to collect". Make Hour, Minute and Second checkbox unchecked.
- Check "Render as a regular field" checkbox on. It is in the "ADVANCED SETTINGS" part in the "SHOW MORE SETTINGS AND VALUES".
4. Open a content add page with the date_popup field created above attached.
5. You cannot see the label for the date_popup field (This is not an intended behavior, I believe).
Here is a patch. The patch's approach is based on the approach of date module. I just applied it to date_popup.
I'd like someone to test/review it. Thank you in advance.
(It may be better to change the issue title if my recognition is correct (if this issue is only for date_popup).)
Comment #3
hgoto CreditAttribution: hgoto as a volunteer and at Studio Umi commentedComment #4
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedI was easily able to reproduce this issue using the detailed steps to reproduce, thank you! The 3 year old patch in #2 to date_popup.module still applies cleanly to the latest 7.x-2.x-dev and fixes this issue for me for date_popup.
Comment #5
FireHawkX CreditAttribution: FireHawkX commentedSorry if i reply to an old thread, but I am using the Date Module with only Year, also rendered as a regular field.
I tried applying this patch, which applied to latest date module perfectly, but the problem is not fixed in my case.
I am using the Select List widget (In the content type manage fields, i only have select list or text field as widget)
Yet the label still does not appear...
If i go to the Advanced settings and set "Position of date part labels", those works, but thats not what I need sadly...
I have another date as select list which has year, month, day, hour, minute, and that one always worked and the label displays properly...
Any suggestion on how i can fix it on my end?
If I should have made a new bug report or anything differently please let me know so I can improve! :)
Thank you very much for your time and have a nice day!
Comment #6
aurelianzaha CreditAttribution: aurelianzaha at jobiqo - job board technology commentedHi,
I had a bit different issue, but the attached patch might solve the original problem as well.
The issue that I had is that the label of the main field was not rendering when granularity of date only was selected, although the 'Position of date part labels' was none.
Comment #7
klausiI think this makes sense in principle.
I think we should not call field_info_instance() in a theme function. Instead all necessary variables should be prepared before either in a preprocess or as theme variables.
Maybe we can't change that at this point? Would that be an API change in date module?
the logic is a bit weird. First it is set to 'none' and then that might be reversed. Can we move the setting to 'none' down in an else{}? Then we don't need $original_title_display.
Comment #8
aurelianzaha CreditAttribution: aurelianzaha at jobiqo - job board technology commentedThanks @klausi for feedback, I had a closer look at the $variables array and it contains the field instance, so no need to load it.
Attached the updated patch.
Comment #9
aurelianzaha CreditAttribution: aurelianzaha at jobiqo - job board technology commentedComment #10
klausiLooks good to me now, thanks!
Comment #11
ahmed_h CreditAttribution: ahmed_h at Iksula commentedComment #12
DamienMcKennaThis looks reasonable, though I adjusted it slightly.
Comment #13
DamienMcKennaCommitted. Thank you.