The views filtering is really handy, but some times being able to filter on the fields you're displaying doesn't really work or is undesired. For example an addressfield where there are multiple values or location where you need the extra processing of the views filter handler.

Although exposed filters are normally set via a form, you can manually set it against the view before it is executed and it will treat it as though given via a form. I think doing this would be a great way to extend the functionality of the views selection handler. In fact I think it could completely replace the way you currently select which fields to filter on with something a whole lot more powerful!

Comments

andrewbelcher’s picture

Status: Active » Needs review
StatusFileSize
new3.94 KB

Ok, so here is a first go at a patch.

What it does:

  • Adds an option to the style plugin so you can choose to send the autocomplete text to the exposed filters.
  • Set the value on the exposed filters before executing.
  • Validates that if you have selected exposed filters, there are actually filters exposed.

This gets it to the point where it is useful and solves the use case I need right now... I've got a couple potential improvements below and there will be whole host of others, but I think a lot of it will be more about making sure someone who doesn't know what they are doing gets some helpful validation/help text to avoid and correct potential errors.

Things that could be improved:

  • There is no validation that the exposed filter can take the given value. Not really had a close enough look to see if this is something easy to resolve.
  • The instance setting for the 'contains' vs 'starts with' is ignored. This is a little complicated, as the exposed filters open you up to do a whole lot more than just contains/starts with (for example location based searches). This could be improved by some help text or solved through a few different options.
tbkot’s picture

Issue summary: View changes
StatusFileSize
new3.94 KB

In PHP 8 the patch in #1 causes the warning:

Warning: Trying to access array offset on value of type null in entityreference_plugin_display->pre_execute() 
(line 60 of /app/app/modules/contrib/entityreference/views/entityreference_plugin_display.inc).

Here is updated patch

Status: Needs review » Needs work

The last submitted patch, 2: 1989952-2-allow_match_on_exposed_filters.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.