Problem/Motivation
The 'Put the exposed form in a block' setting is not available on block displays, but it would be very useful with page manager and layout builder. It would provide much more control of the layout.
Proposed resolution
Currently \Drupal\views\Plugin\views\display\Block::usesExposedFormInBlock() returns $this->hasPath(). This can be changed to TRUE.
This will work well, because views always uses <current> route when view-URL/display-path is not available, for example: http://cgit.drupalcode.org/drupal/tree/core/modules/views/src/Form/Views...
Remaining tasks
+ write patch
- review
User interface changes
The "Exposed form in block" option will be available on block displays.
API changes
None.
Data model changes
None.
Comments
Comment #2
leksat commentedComment #3
leksat commentedComment #5
ademarco commentedI queued this patch for testing against 8.1.x.
Comment #6
sonfdPatch working for me.
Comment #7
claudiu.cristeaWhat happens if you try to place such a block using the core "Block layout" mechanism. Is the exposed block showing?
Comment #8
leksat commented#2 does not work with Drupal 8.1.3.
Comment #10
dan2k3k4 commentedUpdated for 8.2.x and 8.3.x
Comment #11
dan2k3k4 commentedUpdated for 8.2.x / 8.3.x
Comment #12
dan2k3k4 commented- forgot to update status to needs review [my first 'patch' - Sorry for spamming you guys <3]
Comment #14
dan2k3k4 commentedComment #15
dan2k3k4 commentedComment #16
yogeshmpawarRerolled the patch against 8.3.x because #11 failed to apply.
Comment #18
vasi1186 commentedThe #8 and #11 patches seem to be quite different. With #11, it is true it applies on 8.2, but it does not work, I cannot see the option anymore on the view edit form.
I attached a new patch.
Comment #20
vasi1186 commentedThis one should apply (at least for 8.2)
Comment #22
vasi1186 commentedOne more try.
Comment #24
blazey commentedPatch from #22 works flawlessly.
Comment #25
saltednutHas anyone else tested this with an exposed form that has a 'Reset' button? This is what we are seeing when we try to Reset any exposed forms that are attached to a Views block.
Redirect, 404:
/views/ajax?field_tags_target_id=downtown+%288%29&sort_by=created&sort_order=DESC&op=ResetEdit: Some notes about reproducing...
The View Exposed Form setting 'Exposed form in block' needs to be set to "No" to replicate this. Using this patch, when 'Exposed form in block' is set to 'No' the exposed form still shows up and the form works, but it is attached to the top of the Views block. If the exposed form style is 'Basic' and "Include reset button (resets all applied exposed filters)" is checked, then the "Reset" button will show up.
The 'Reset' button will NOT show up at all if 'Exposed form in block' is set to 'Yes' -- this appears to be by design.
Comment #26
claudiu.cristeaWell. It needs tests, anyway. So, yes, "Needs work".
Comment #27
lendude@brantwynn sounds like you are running into #2820347: Exposed filter reset redirects user to 404 page on AJAX view when placed as a block, which is unrelated to this feature.
Some basic tests for this, basically the page test now applied to a block display.
Comment #33
keszthelyi commentedReroll for 8.7.x of #27
Comment #37
nickdickinsonwildeBeen using #33 for a year+ with no problems on D8.7 > 8.8 > 8.9. Using #33 on new Drupal 9.0>9.1 as well. Works seemlessly.
Comment #38
quietone commentedRe uploading the patch from #33 to make sure it tests with 9.2.x
Comment #39
alexpottThis test is not clicking on any buttons. I think it is worth testing that.
I think we should test that the submit buttons work. So change the end of the this test to do something like:
Comment #40
raman.b commentedAddressing #39
Comment #41
handkerchiefMeanwhile: my dirty workaraound:
https://www.drupal.org/project/drupal/issues/2692297#comment-13970958
Comment #42
pameeela commentedComment #43
pameeela commentedComment #44
pameeela commentedComment #45
abhijith s commentedApplied patch #40 and it works fine.The exposed form in a block option will be available for block displays after applying this patch.
Before patch:

After patch:

RTBC +1
Comment #46
mpotter commentedSince #39 was addressed, moving this back to RTBC. It works as designed for me also and fixes a major issue with using exposed filter blocks on non-ajax views.
Comment #49
catchRestoring status after HEAD was broken
Comment #51
catchCommitted 9f8f38d and pushed to 9.3.x. Thanks!
Comment #53
codebymikey commentedIf the View has an alternative page display, it'll default to picking the first URL it can find (even if that view might be for a different purpose e.g. for a REST API).
References:
ViewsExposedForm::buildForm()ViewExecutable::hasUrl()Integration with "Link display" would be useful for controlling where the form submits to, or making use of
ViewExecutable::$override_url.