I've been working on #501428: Date and time field type in core. The Field module automatically adds filters and arguments to views for its fields, but it bases its choice on the data type. The date field uses a varchar field to store the date, so it gets the 'string' filters and arguments'. Instead I want to use 'date' filters and arguments. Ultimately I will create a custom filter and argument but for now I just want to confirm that I can replace the 'string' filter with some other option.

There are two ways to alter the data, hook_views_data_alter() or hook_field_views_data_views_data_alter(). I've tried both but can get neither to work. The only thing the alter is doing is replacing the 'string' id with 'date'.

If I use views_fetch_data() to inspect the data array, my values seem to be in there. But if I create a date field and then create a view and try to add a filter for that date field, the filter form is the string filter form, not the date filter form. I've tried clearing caches multiple times, but no matter what I keep getting the string filter form. I briefly saw the date filter form one time in all my attempts, but when I checked the box to expose the filter it snapped back to being the string filter form again.

I tried digging into the code to see where the problem might be coming from but came up empty. My thought is that the configuration system is caching something it shouldn't.

I'm marking this major since this is something that ought to be possible. Plus it looks like it could lead to broken handlers if there is confusion about which filter to use.

You should be able to reproduce the problem by using the patch above to create a new date field and view and try to add a date filter that uses the date filter form. The date filter won't work right for this field, I'm not worried about that, I just want to make sure there is a way to replace the string filter with something else.

Comments

tim.plunkett’s picture

Issue tags: +VDC, +VDC-integration

Tagging. Will take a look.

dawehner’s picture

The reason, at least from my perspective could be that hook_hook_info does not list these hooks at the moment,
but there are multiple patches in the queue which changes that, for example #1828410: Provide a bulk_form element for actions.
It worked for me probably because i worked with this patch, so the hook_info was part of my current cache.

Let's fix that fast: #1834184: Add basic views hooks to hook_hook_info

larowlan’s picture

Issue tags: +#pnx-sprint

tagging

YesCT’s picture

Status: Active » Postponed
dawehner’s picture

Status: Postponed » Fixed

And this is fixed now.

Thanks for initially creating the bug report.

Automatically closed -- issue fixed for 2 weeks with no activity.