I show a view in my own module, like this: $viewFromDrupal = views_embed_view('storage', 'block');. The view is showing up, but the exposed filter is not working when I place the included view directly after an other view.

When the view $viewFromDrupal is showing at the top of the page the exposed filter works correctly.

Does someone have some experience with this?

Should I include some extra files or something?

  • Is the exposed form displayed inside the view or as a separate block ? Commented Apr 3, 2017 at 22:01
  • I tried both, but with no luck.
    – Appel
    Commented Apr 10, 2017 at 14:39
  • Is there any form alter maybe that prevents the display of that form, is there a specific template for the exposed form , or maybe a view template override that is skipping the exposed form ? . Check in all custom modules + your theme Commented Apr 10, 2017 at 16:21

1 Answer 1


So better to say in your question more details of how it doesn't work, but I'll take a guess...


$view = views_get_view('storage');
$view_markup = $view->preview('block');

I've done this before to render the View, that will give you some markup...

Then I've noticed that the "action" of the form could be incorrect, so you have to do a hook_form_alter implementation and set the #action to the current page path...I'm guessing what the value of $form['#id'] will be, you will need to verify that ...

    function yourmodule_form_alter(&$form, &$form_state) {
    if($form_id == 'views_exposed_form' && $form['#id'] == 'views-exposed-form-storage-block') {
        $path = current_path();
        $form['#action'] = '/' . $path;


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.