I have a Date field that contains a from and to date (e.g. 2012-01-01 to 2012-12-31).
When I want to display this particular field through Views, I have set the formatter settings to "Plain" and the "Display" (key = fromto) to "Start date only".
However, this still shows me "2012-01-01 to 2012-12-31" instead of just "2012-01-01".
I traced this back to date_field_formatter_view() in date.field.inc.
There is a switch on $display['type']
In case this is "date_plain", my date gets run through the following code:
$element[$delta] = array('#markup' => t('!start-date to !end-date', array('!start-date' => $item['value'], '!end-date' => $item['value2'])));
Which is not what I want...
If I select the formatter "Date and time" however, this works correctly, because in that case, theme_date_display_combination() gets called, which has a code block that performs a switch on $options['fromto']
, making sure only the starting date is shown.
I'll probably use the "Date and time" formatter for now, and try to strip out the HTML that is added to it (because that interfers with my use case). However this seems like an inconsistency that should be fixed. Either the "Display" select list should be removed in case "Plain" formatter is chosen, or (better yet) the Plain formatter should take this setting actually into account.
Comment | File | Size | Author |
---|---|---|---|
#5 | date-plain_text_formatter_respect_settings-1763788-3.patch | 1.73 KB | AaronBauman |
Comments
Comment #1
supakitk CreditAttribution: supakitk commentedsame problem. subscribe
Comment #2
AaronBaumanThis issue depends at least in part on #1806856: Manage Display Format Settings won't save when using the "plain" formatter
Comment #3
AaronBaumanSo, the way Date is working now, without the display settings patch I wrote for #1806856, plain text formatter is still broken for entity display settings.
However, Views formatter settings save correctly. Go figure.
So, the attached patch will fix this issue for views fields only.
For standard entity display settings, you must additionally apply this patch:
#1806856-8: Manage Display Format Settings won't save when using the "plain" formatter
(or, assuming that patch fails tests, whatever is the most current patch that passes).
Comment #4
AaronBaumanfixed an extra close-mustache typo
Comment #5
AaronBaumanOK, last one for today.
changes:
#1806856-10: Manage Display Format Settings won't save when using the "plain" formatter
Comment #6
podarokwe can`t commit this without testing coverage
Comment #7
jgSnell CreditAttribution: jgSnell commentedMarked #2129109: Plain formatter with 2 values date doesn't work as a duplicate of this issue.
Comment #8
AaronBaumanComment #9
kalistos CreditAttribution: kalistos commentedI combined this patch with another patch here: https://www.drupal.org/node/1806856#comment-10369151.
Comment #10
Honza Pobořil CreditAttribution: Honza Pobořil commentedI confirm @kalistos' patch from #1806856: Manage Display Format Settings won't save when using the "plain" formatter solves both issues.