Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you follow the standard steps to have an entity browser with two tabs which are
1. an upload widget and
2. a view to select entities
If you have a reset option on the exposed filters when you click on it to reset the view it instead loads the upload tab. I'd expect the reset button to simply reset the view.
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff_7-9.txt | 830 bytes | maximpodorov |
#9 | entity_browser-fix-for-reset-2939481-9.patch | 1.42 KB | maximpodorov |
#7 | entity_browser-fix-for-reset-2939481-7-8.6.patch | 1.31 KB | hawkeye.twolf |
Comments
Comment #2
samuel.mortensonComment #3
John Pitcairn CreditAttribution: John Pitcairn commentedReproducible here. Rats.
Comment #4
Weilinggu CreditAttribution: Weilinggu at Myplanet commentedNoticed that this only happens in Tabs widget selector. Added a check so when user click reset, it wouldn't trigger tab switching.
Logic: If form_state has "op" input, it means it's coming from view, there is no reason to trigger submit in Tabs.php
Comment #5
Weilinggu CreditAttribution: Weilinggu commentedComment #6
marie.pinet CreditAttribution: marie.pinet at Smile commentedHi,
I have a same problem in my project.
I have "2 types" of entity browser :
Without this patch, when I click on the reset button :
With this patch, when I click on the reset button :
When I make a breakpoint in the submit function patched, I can see that the trigger element is bad.
For examples :
But I don't have find where is the problem.
Thanks for your help.
Marie
Comment #7
hawkeye.twolfNew patch attached to fix issues caused by the previous patch when the Views widget was not first in the list of tabs.
Comment #8
maximpodorov CreditAttribution: maximpodorov commentedReset button can have translated or even modified label.
Comment #9
maximpodorov CreditAttribution: maximpodorov commentedThis patch adds checking against the translated "Reset" string.
Comment #10
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedPatches not working against the stable 8.x-2.4 release.
Comment #11
tekNorahSuccessfully applied patch against 8.x-2.5 & 8.x-2.6 release.
Can we get this in the next release, please?
Comment #12
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedWorks for us too on 8.x-2.6 with modal + single widget. Thanks for the patch!
+1 RTBC
Comment #13
BerdirThe reset button string is configurable, getTriggeringElement() might allow to identify that more easily?
Comment #14
BerdirComment #15
plopescHello,
I've been digging into this one and it seems that
$form_state->getTriggeringElement()
is not returning the Reset button, but the tab selector button added inWidgetSelectorBase::getForm()
.Apparently, when clicking on the "Reset" button, the form being submitted is the parent one and to the views exposed one.
I have the feeling that will be necessary to add some JS in
entity_browser.view.js
to capture the Reset button event and proceed accordingly.Another option would be to load the view in
EntityBrowserForm::submitForm()
and compare the button value with the value stored in the view. However, that would open the door to inconsistencies with other modules like BEF or custom exposed form plugins.What do you think?