I created a view with exposed filters. The only purpose of the filters is to have url query parameters, which are controlled through custom UI elements.

There is no purpose in displaying the exposed form.

I can think of a number of ways to get rid of the form. But they all involve custom code that directly targets the view id. So it will be throwaway code, not reusable.

Another option could be to put the exposed form into a block, and then simply not display this block. But this will produce noise in features.

I wonder if there is a more elegant way to do this. E.g. a contrib module or a piece of custom code which gives me a checkbox in Views UI where I can say "don't show an exposed form". Maybe an exposed form plugin which does not display the form at all..

2 Answers 2


If you're using hidden exposed filters instead of contextual filters, then you're already on a bit of a hacky path so you might as well just hide the filters with css.

If you think the contextual filters won't work which is sometimes the case, then the elegant solution is using the Global:Null contextual filter + Views Argument Substitutions to use parts of the url in the normal filters.

But really, just hide it with css.

  • The reason to use exposed filters was that I want to replicate an already-existing url structure with query parameters. Afaik, contextual filters don't give me url query params. Or do they?
    – donquixote
    Dec 10, 2016 at 11:55
  • No, I don't think so. So will you do it with css or some other method? Dec 10, 2016 at 12:06
  • CSS is ugly and also requires to target a specific view. I think what I will do is create a reusable exposed form plugin "hidden form" which simply does not show the form. I don't know about the details yet, but will post the solution here.
    – donquixote
    Dec 10, 2016 at 12:09

Here is my solution with a custom views exposed_form plugin. I don't know if this the best way to do it, but it seems to work.

Create a module views_unexpose, with dependencies views and xautoload. The latter is optional, depends how you want to organize your class files.

In src/ViewsPlugin/ViewsPlugin_ExposedForm_Unexpose.php:


namespace Drupal\views_unexpose\ViewsPlugin;

class ViewsPlugin_ExposedForm_Unexpose extends \views_plugin_exposed_form_basic {

   * @param bool $block
   * @return string
  public function render_exposed_form($block = FALSE) {
    // If the parent method is not called, the entire view will be empty.
    // Ignore the return value from the parent method, return '' instead.
    return '';


In views_unexpose.views.inc:


use Drupal\views_unexpose\ViewsPlugin\ViewsPlugin_ExposedForm_Unexpose;

 * Implements hook_views_plugins().
function views_unexpose_views_plugins() {
  $plugins = [];

  $plugins['exposed_form']['unexpose'] = [
    'title' => t('Unexpose'),
    'help' => t('Completely hides/removes the exposed form.'),
    'handler' => ViewsPlugin_ExposedForm_Unexpose::class,

  return $plugins;

In views_unexpose.module:


 * Implements hook_views_api().
 * @see views_unexpose_views_plugins()
function views_unexpose_views_api() {
  return array(
    'api' => 3,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.