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.
To reproduce:
-Create content type with a Date field
-Go to the "Manage Display" tab for that content type
-Set format for the date field to "Plain"
-Click the gear button to customize its display
-Change the display format from "Long" (the default) to something else, "Medium" "Short" etc...
-Click "Update" then click "Save"
The changes are not saved.
Comments
Comment #1
smartvinay CreditAttribution: smartvinay commentedI followed the steps given by you above, initially it was not getting saved as you said but later when i Cleared the Cache it started displaying the proper date format which is selected.
Solution : Clear the Cache
Comment #2
smartvinay CreditAttribution: smartvinay commentedIn my previous post I mentioned to clear the cache but that is not the solution.
If you select the Plain format then it will display the date in only one format. To change the display format settings change the format from Plain to Date and Time
PS: dont forget to click save button on Manage Display Page after doing the changes else the settings wont reflect
Comment #3
MorganL CreditAttribution: MorganL commentedNo amount of cache clearing fixed the original scenario for me. However, after changing from "Plain" to "Date and time", the display format setting is now saving and sticking. Thanks!
It seems that there is still an issue with the "Plain" format settings not saving.
Comment #4
mstrelan CreditAttribution: mstrelan commented#3 is accurate. You can change the date format if the field is using the "date and time" formatter, but not the "plain" formatter.
Comment #5
mstrelan CreditAttribution: mstrelan commentedFurther to my post in #4 even if the settings did save they wouldn't do anything. You can make them save by modifying
date_field_formatter_info()
and duplicating the settings fromdate_default
todate_plain
butdate_field_formatter_view()
also needs to be adjusted.Since I don't know the background behind the plain formatter I don't want to mess with it. Instead I have created a patch that adds a "Strip HTML tags" setting to the date default formatter which fulfils my needs, but this is really just for reference, as it doesn't address this issue description.
Comment #6
joehudson CreditAttribution: joehudson commentedCache clears, setting the format to Date and Time, neither made a difference to the issue for me. Still not able to set a date format to display the date under view modes other than default..
In the mean time I've resorted to using DateObject to parse the date strings and work from there.
Comment #7
Sylvain Lecoy CreditAttribution: Sylvain Lecoy commentedGod this module is so buggy... Thanks mstrelan for the fix it did it for me as well :-)
Comment #8
AaronBaumanThanks for the contrib, mstrelan.
Here's the patch you allude to, which adds the same settings from date_default to date_plain.
I think this is more appropriate to solve the issue.
As for the problem with date_field_formatter_view(), that's actually being addressed distinctly, in at least one other issue:
#1763788: Plaintext field formatter doesn't take "fromto" setting into account
Comment #9
AaronBaumanComment #10
AaronBaumanOne more adjustment.
Now that we're saving settings for date_plain formatter, we can (and should) fix date_formatter_format() at the same time.
Comment #11
vijaycs85Thanks for working on this. Seems like patch in #10 trying to make date_plain to act as same as date_default. Not sure this is what we want to do. if so, we can remove the format of date_plain. Otherwise we have to find the use case of date_plain and implement it. Comment (or usecase) from anyone using date_plain format is highly appreciated.
Comment #12
mstrelan CreditAttribution: mstrelan commentedI'm wanting to use #10 to get timestamps in json views for services. The fromto setting is ignored. It needs something like this:
Comment #13
AaronBaumanre #11: given the patch in #10 date_plain now works similarly to date_default, but renders without additional HTML markup.
see date_field_formatter_view() for specifics.
Without the patch, any date format given in display settings is ignored when using date_plain.
Comment #16
Valentine94Re-roll of #10.
Comment #17
andypostwhy not affected if in scope of the subject
Comment #18
AaronBaumanI think you're asking why the case statement for "date_plain" was removed.
In this patch, "date_plain" format is affected -- it falls through to the "default" case.
Comment #19
gabriel.achille CreditAttribution: gabriel.achille commented@vijaycs85: In the present situation it is very misleading to let admin choose a date format for the plain formatter... and not using it in the display. My use case for this is to be able to generate a feed (RSS, JSON...) of articles: it is necessary to format the date without the HTML tags introduced by date_defaut formatter.
However the patch #16 is not working: the formatter settings is saved but not used in date_field_formatter_view(). Here is a new patch with the following changes:
Comment #20
gabriel.achille CreditAttribution: gabriel.achille commentedComment #21
gabriel.achille CreditAttribution: gabriel.achille commentedComment #23
kalistos CreditAttribution: kalistos commentedPatch #19 doesn't support "fromto" settings.
So it would be better to chose date if my field has 2 dates (start and end).
This featrue was provided by this patch https://www.drupal.org/node/1763788#comment-7882163, but it requires another changes from current patch.
I combined two patches and get this patch.
Comment #24
icf-vpathak CreditAttribution: icf-vpathak commented#3 works!! thanks guys.
Comment #25
Honza Pobořil CreditAttribution: Honza Pobořil commentedPatch #23 solves both issues!
Comment #26
pvdjay CreditAttribution: pvdjay as a volunteer commentedI couldn't seem to get the patch from #23 to apply on the latest 7.x-2.x code. I've rerolled a working patch.
Comment #27
pvdjay CreditAttribution: pvdjay as a volunteer commentedNot sure why the patch appeared twice above. Updating issue metadata.
Comment #28
pvdjay CreditAttribution: pvdjay as a volunteer commentedComment #29
Honza Pobořil CreditAttribution: Honza Pobořil commentedRerolled patch #26 still working (for both issues).
Comment #30
DamienMcKennaRerunning the tests, lets see how this works.
Comment #31
emerham CreditAttribution: emerham commentedJust tested on PHP 7.1, all works there as well
Comment #32
DamienMcKennaI think it might be worthwhile creating a test for this before committing it.
Comment #33
DamienMcKennaIt should be simple-ish to create tests for this.