Twig dump function in the exposed form
After updating my site from Drupal 10.0.9 to Drupal 10.1.0 and then to 10.1.1. Disappeared my views exposed filter. I have custom code in a hook form alter. Change theme, delete code, but no solution came.
Then I installed a new Drupal site, with the steps below. First with version 10.0.9.. no problem. Then with 10.1.0 and 10.1.1. A {{ dump() }} inspection of the view-exposed-form.html.twig yields no results and the exposed form disappears. This only if an exposed filter of type taxonomy term is created. With other filters, not of this type, everything functions normally.
Because this was done in a fresh installation, without any custom code, without any other module, nor themes, I suspect this is a bug. Unfortunately I can't find the solution myself.
Steps to reproduce
- Create a vocabulary.
- Create a custom content type
- Create a view page, with filter criteria to the newly created content type. : Unformatted list, Content: teaser
- Create an exposed filter to select the taxonomy terms via multi select. Possibly create other exposed filters that do not refer to a taxonomy term.
- Exposed form in a block : yes.
- Add the exposed form block to anny region on your page
- Add a {{ dump(form) }} function to view-exposed-form.html.twig
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | view-block.png | 450.73 KB | shailja179 |
Comments
Comment #2
shailja179 commented@Belba,
This is expected as its already mentioned in views setting. Attaching the screenshot.
Check this note when you try to put exposed form in block.
If set, any exposed widgets will not appear with this view.
Comment #3
belba commentedComment #4
belba commented@shailja179
Thank you for the answer. I did add the block, with the exposed form to the header of my page. I updated this in the steps. I should have been more clear. The issue persist.
Comment #5
cilefen commentedComment #6
shailja179 commentedYes, you can add that form in other part of view(header,footer) as a block. Thats why we need to expose filter in block otherwise it comes above view if we don't expose to block.
Comment #7
shailja179 commentedSorry title changed by mistake.
Comment #8
smustgrave commentedMoving to active as there is no patch to review
Comment #9
lendudeTried the steps to reproduce, my steps:
* Umami install on 11.x
* Create node View
* Add title filter, exposed
* Expose filters in block
* Add block to page header => Filter show on every page
* Add filter on 'Tags', dropdown, exposed, allow multiple
* Reload page with the filters => Filters still show
What critical step am I missing to reproduce this?
Comment #10
belba commented@Lendude
Thanks for the follow up.
The most important step is that there must be a filter of type entity reference(taxonomy) field in the exposed form.
To save work you can make views of articles and in the filter criteria make a filter on the 'field_tags'. Also create a filter for the titles, as you did in the previous section. The exposed filter is shown!
Then go to the TWIG template responsible for displaying the views exposed form : views-exposed-form.html.twig. Do a {{ dump() }} function to inspect the variables. The result is not displayed, the exposed form disappears.
Remove the filter from the type entity reference field of the views filter. Everything works as expected. The problem only arises with fields of type entity reference(taxonomy).
The problem is not there in version 10.0.9. It does in both versions 10.1.0 and 10.1.1.
Comment #11
bryanmanalo commentedAlso experiencing this issue. I am surprised that this has not gained a lot of traction. Seems like a big issue for existing sites with lots of views with exposed filters with taxonomy term reference
Comment #12
bryanmanalo commentedFor us the issue was from this particular patch from core: https://www.drupal.org/node/2898635. When this patch was removed, the filters were back.
A colleague was able to discover this issue for us.
Comment #14
smustgrave commented@belba can you add the exact steps you took to the issue summary please.
Comment #15
smustgrave commentedWasn't able to replicate this one on D11, so closing out. If still a bug please please reopen.