

$build = views_embed_view('ajax_test', 'embed_1') Edit the description method and append the following before the "return $build" line:.Open 'Drupal\page_example\Controller\PageExampleController'.Install and enable the Page Example module to create a sample page we can embed into.I'm going to use the Page Example module from the Drupal Examples for Developers set of modules for the dummy page needed to create an embedded view display, but it can be embedded in other ways and would still work the same.

Now we need to embed this view into a page. In the Exposed Form options, make sure Basic is chosen as the type and in the settings check off the box that inserts a Reset button.Under Advanced Options, enable AJAX for this view.Check the "Expose this filter to visitors" box. Add the Title field to the Filter Criteria with the filter configured to use the Contains operator.Edit the Title field to give it a label of "Title".In the settings make the title field sortable I'll use this more elaborate scenario in my steps below. If both of these displays exist in the same view, then the form's action attribute for the filter in the Embed display will be rewritten to submit to whatever path you setup for the Page display. When the Reset button is pressed, it'll direct you to /views/ajax instead of your current page.Ī variation of this bug is if you have both a Page display setup and an Embed display setup in the view. This issue is harmless unless the filter in your embedded view uses the Reset button to clear the form and reload the page. When a view is setup to use the "Embed" display in a view, using AJAX in the form in any way will cause the action attribute of the HTML form object to be rewritten to submit to '/views/ajax' instead of the current page.

This is a tricky one, this could be as involved as rewriting the Drupal\views\Plugin\views\display\DisplayPluginBase::getLinkDisplay logic. This results in Reset buttons redirecting to other displays for example. When an embedded view display (such as a block) has exposed filters, if the view also contains a display with a path (page, export, etc) then the exposed form action will be set to the other display's path.
