Drupal core views finally has support for the "html5 placeholder" in views (see the related issue).

It has default support for the core view displays. But Search API doesn't support this yet for "fulltextsearch" and will need to add support for it.

At least that's what I understand from these 2 comments:
Question:

I looked in to the proposed approach in #5, but I don't think this is a good solution.
Lets assume we add the placeholder attribute in the plugins "StringFilter" and "NumericFilter". This fixes the problem for Drupal core filters. But for example if we have a "SearchApiFulltext" provided by SearchApi then we won't be able to configure the placeholder because this plugin does not provide it.

There are a lot of other modules that expose custom filter plugins and the placeholder attribute should be configurable on all of them without the developers of the module having to alter their plugin.

Answer:

I would lean toward the approach in #5. As we've already established, placeholder text only applies to particular form elements. As far as I can see, there's no way for us to generically apply it at the FilterPluginBase level. It depends on the widget provided by each individual filter plugin, and only that plugin is going to know for sure where and how a placeholder should be applied.

To take an example out of core, if you're using a NumericFilter with the BETWEEN operator, the value form contains both a "Min" and a "Max" field, not just a singular "Value" field. You may well want a placeholder for both of those fields, but FilterPluginBase is going to have no idea how to accommodate that — only NumericFilter does.

And yes, that means that any contributed module's filter derived from FilterPluginBase directly (like SearchApiFullText) will not magically inherit placeholders. Not ideal, but I'm not sure its avoidable.

Comments

bskibinski created an issue. See original summary.

bskibinski’s picture

Issue summary: View changes
drunken monkey’s picture

Component: General code » Views integration
Status: Active » Needs review
StatusFileSize
new2.28 KB

Thanks a lot for reporting this!
I wasn't aware of this change, but it really seems like something we should support. Also, luckily, it doesn't seem like something that depends on this being present in Core – we can use it right away, even for users who are still using Drupal 8.4.

Does the attached patch work for you?
Seems like we only need to adapt the fulltext filter ourselves, all others should already be covered by the Core change.

bskibinski’s picture

Status: Needs review » Needs work

Awesome, thanks for the quick reply and patch!

I've tested it in Drupal 8.4.5 with search API 1.7

It works like a charm, but isn't translatable yet through the "Translate view" tab.
If that could be added, that would make it perfect.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new459 bytes
new2.26 KB

This should fix the problem in #4.

bskibinski’s picture

Status: Needs review » Reviewed & tested by the community

Perfection achieved.
Patch #5 applied without any problems, let's get this puppy comitted :-)

Thanks for the quick support on this one guys!

  • drunken monkey committed 5ffd1d7 on 8.x-1.x
    Issue #2948659 by drunken monkey, borisson_, bskibinski: Added support...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks again for your feedback! And thanks a lot, of course, to Joris for the fix.
Committed.

Status: Fixed » Closed (fixed)

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