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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smartvinay’s picture

I 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

smartvinay’s picture

In 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

MorganL’s picture

No 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.

mstrelan’s picture

Title: Manage Display Format Settings won't save » Manage Display Format Settings won't save when using the "plain" formatter

#3 is accurate. You can change the date format if the field is using the "date and time" formatter, but not the "plain" formatter.

mstrelan’s picture

Further 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 from date_default to date_plain but date_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.

joehudson’s picture

Cache 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.

Sylvain Lecoy’s picture

God this module is so buggy... Thanks mstrelan for the fix it did it for me as well :-)

AaronBauman’s picture

Thanks 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

AaronBauman’s picture

Status: Active » Needs review
AaronBauman’s picture

One more adjustment.
Now that we're saving settings for date_plain formatter, we can (and should) fix date_formatter_format() at the same time.

vijaycs85’s picture

Issue summary: View changes
Status: Needs review » Postponed (maintainer needs more info)

Thanks 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.

mstrelan’s picture

I'm wanting to use #10 to get timestamps in json views for services. The fromto setting is ignored. It needs something like this:

<?php
          if ($settings['fromto'] == 'value' || empty($item['value2']) || $item['value'] == $item['value2']) {
            $element[$delta] = array('#markup' => $item['value']);
          }
          elseif ($settings['fromto'] == 'value2') {
            $element[$delta] = array('#markup' => $item['value2']);
          }
?>
AaronBauman’s picture

Status: Postponed (maintainer needs more info) » Needs review

re #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.

Status: Needs review » Needs work

The last submitted patch, 10: date-date_plain_format_settings-1806856-2.patch, failed testing.

Valentine94’s picture

Status: Needs work » Needs review
FileSize
1.03 KB

Re-roll of #10.

andypost’s picture

+++ b/date.module
@@ -426,9 +426,6 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
     case 'format_interval':
       return 'format_interval';
...
-    case 'date_plain':
-      return 'date_plain';

why not affected if in scope of the subject

AaronBauman’s picture

why not affected if in scope of the subject

I 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.

gabriel.achille’s picture

@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:

  • format the date in date_field_formatter_view() for date_plain
  • update date_default_formatter_settings_summary() to reflect choosen format for date_plain
gabriel.achille’s picture

Status: Needs review » Needs work
gabriel.achille’s picture

Status: Needs work » Needs review

kalistos’s picture

Patch #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.

icf-vpathak’s picture

#3 works!! thanks guys.

Honza Pobořil’s picture

Status: Needs review » Reviewed & tested by the community

Patch #23 solves both issues!

pvdjay’s picture

pvdjay’s picture

Status: Reviewed & tested by the community » Needs review

Not sure why the patch appeared twice above. Updating issue metadata.

pvdjay’s picture

Honza Pobořil’s picture

Status: Needs review » Reviewed & tested by the community

Rerolled patch #26 still working (for both issues).

DamienMcKenna’s picture

Rerunning the tests, lets see how this works.

emerham’s picture

Just tested on PHP 7.1, all works there as well

DamienMcKenna’s picture

I think it might be worthwhile creating a test for this before committing it.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

It should be simple-ish to create tests for this.