Skip to main content
3 of 3
Commonmark migration

I posted the following as a bug report to Drupal Core

When a custom entity is created, and one of the fields is a datetime FieldType, views filters are not treating this field like a datetime field, but, instead, like a string. Timestamp Fieldtypes on the other hand are presented with the correct filter options.

The response I received was:

Yes, it does default to a string. I think the underlying reason is this:

Datetime support comes from the datetime module, so if you want your entity to use that, add a dependency to datetime and override any defaults for your entity in an extension of \Drupal\views\EntityViewsData.

The Views 'date' filter only works for timestamps (hence your timestamp fields work out-of-the-box), so just setting the filter plugin_id to 'date' won't help either.

So this works as designed I think.

Kevin Nowaczyk
  • 1.4k
  • 3
  • 13
  • 37