Data is not formattable when used as a filed.

Created on 13 January 2025, about 1 month ago

When I add the recurring date to a view as a field it cannot be formatted as a date. Internally the default search_api widget is used, which outputs the data as a timestamp.

I managed to mitigate this by using the following code:

function <em>hook</em>_views_data_alter(array &$data) {
  $data['search_api_index_{$index_id}']['{$index_field_name}']['field']['id'] = 'search_api_date';
}

While this work-around is simple to implement it would be nice for the module to correctly set the field widget automatically as the code will need to be added for each index and field. The work-around only works for the "(indexed field)" variant of the data.

Weirdly the end_date gets the correct field widget, it's just then start value that cannot be formatted.

Field set-up:

Output without work-around:

Output with work-around:

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom John Cook

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @John Cook
  • 🇬🇧United Kingdom joachim

    Do you mean the recurring date field, or the date occurrence computed field?

    If it's the recurring date field, then it's a problem with Date Recur module. If it's the computed field, then the problem is probably in Search API, as the computed occurrence field is of type daterange.

    This module doesn't actually declare any fields to the search index - our datasource plugin inherits from the one for entities in SearchAPI, and doesn't override getPropertyDefinitions().

Production build 0.71.5 2024