Problem/Motivation
Field widget + entity browser with view widget with "automatically submit" option throws exception.
Steps to reproduce
- create content type
- add media reference field
- create media reference view with entity browser display
- create media reference entity browser
- add view widget using the entity browser just created, check "automatically submit" option
- edit field widget settings and choose entity browser and save
- go to add your new content type and when clicking on link to open entity browser, you get the config exception.
Proposed resolution
- Ideally, fix this configuration to work.
- Other, worse solution, add warning when trying to add entity browser to field.
Remaining tasks
- all
Original issue text
in creating an image browser > widget part
admin/config/content/entity_browser/image_browser/widgets?js=nojs
if you enable "Automatically submit selection"
and use the image browser as a widget for a media image field
the form (popup) opens with following message
the website encountered an unexpected error. please try again later
and in database log
Message Drupal\Core\Config\ConfigException: Used entity browser selection display cannot work in combination with settings defined for used selection widget. in Drupal\entity_browser\Form\EntityBrowserForm->isFunctionalForm() (line 160 of /var/www/vhosts/domain.com/httpdocs/web/modules/contrib/entity_browser/src/Form/EntityBrowserForm.php).
Severity Error
Message Drupal\Core\Config\ConfigException: Used entity browser selection display cannot work in combination with settings defined for used selection widget. in Drupal\entity_browser\Form\EntityBrowserForm->isFunctionalForm() (line 160 of /var/www/vhosts/domain.com/httpdocs/web/modules/contrib/entity_browser/src/Form/EntityBrowserForm.php).
Severity Error
if you uncheck "Automatically submit selection" entity browser is working as it should
Comment | File | Size | Author |
---|---|---|---|
#14 | multi_step_selection_with_automatic_select_2853751_14.patch | 1.64 KB | maticb |
#12 | this should be avoided.png | 276.66 KB | oknate |
#7 | views.view_.asset_browser.yml | 22.19 KB | rwam |
#7 | entity_browser.browser.multiple_image_browser.yml | 1.49 KB | rwam |
#2 | entity-image-browser.automaticall-submit-selection-enabled.jpg | 26.74 KB | GiorgosK |
Issue fork entity_browser-2853751
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
GiorgosKhere is screenshot of setting and the error
Comment #3
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedWhich selection display are you using? This feature (Automatically submit selection) can currently work only with the Multi step selection display.
Comment #4
marcoscanoPostponing until we have more info on how to reproduce.
Please feel free to re-open when that is the case.
Thanks!
Comment #5
bceyssensWe are experiencing the same issue. We were using the No selection display when suddenly the upload functionality broke after a module-update. If this functionality is only available for the Multi step selection display, it shouldn't be accessible when another display is configured.
Comment #6
juliencarnot CreditAttribution: juliencarnot at oqp.io commentedSame here, I'd like to use the "No selection display" and "Automatically submit selection" for simpler file uploads from contributors' devices (like the default input file UI but with thumbnailing, progress bar and client-side resizing)...
Comment #7
rwam CreditAttribution: rwam commentedSorry, it doesn't. If I check this option I get an AjaxError:
for the following path:
http://drupal.localhost/views/ajax?_wrapper_format=drupal_ajax
Attached you can find my config for the entity browser and the corresponding view.
With disabled option the entity browser works fine.
FYI: I'm using media in core with Drupal 8.4.4 and Entity Browser 8.x-2.0-alpha2
Comment #8
glass.dimly CreditAttribution: glass.dimly commentedMy use case here is a single-select field. Multi-step as well as the selection button allow for the selection of multiple items.
Comment #9
alienzed CreditAttribution: alienzed commentedno fix yet?
Comment #10
oknateI was able to reproduce with 8.x-2.1.
I'll see if there's a way to fix this. This seems like basic functionality that should be there.
Comment #11
oknateComment #12
oknateComment #13
oknateComment #14
maticb CreditAttribution: maticb commentedThis does not seem like a problem with the entity browser, you merely need a selection distplay plugin that supports this.
I created a simple patch for the multi step display plugin, that adds a checkbox in configuration for this. When this checkbox is checked, I add a submit command after we are done loading the images:
Keep in mind this will only work if you do not have required fields on the entity create form. So if you are using it with media entity images, you must disable the alt and title attributes. Otherwise it will do nothing, because you are missing required fields.
Comment #15
TokiWorking with Drupal 8.8.4 and Entity Browser 8.x-1.10
Tried the patch above but no luck.
In my case, I have tried to combine Entity browser (nodes, not media) with a Views widget.
People may chose one location through multiples small maps displayed on a modal grid.
My client needs an autosubmit on this location choice.
Combination "No Selection Display" and "Automatically submit selection" on the View widget plugin failed each time, unfortunately.
I have tried with "Multistep selection display" (if I am correct, no need in my case, one choice, one click and you're good), with and without the patch and it still does not work.
Does anyone has a solution or a workaround for site builders like me?
Comment #16
maticb CreditAttribution: maticb commented@toki, my patch is sort of "hack-ish" and is probably not a final solution, but a temporary one.
What exactly was your error? Because I am using this patch on a live site, that I created it for and it works fine. As said, please make sure there are no required fields on your form, as my patch simply triggers the click event on the button. Perhaps there is some delay in loading and the button doesn't exist at the time when my patch already triggers the event?
Comment #17
Toki@maticb, thanks for answering me, even if the patch is 7 months old.
I have tried again and finally managed to make it work!
I thought that your patch and its checkbox in Selection Display Plugin Settings (Multi Selection Display) would make the autosubmit work alone but I need to check also the Automatically submit selection checkbox on the Widget settings.
With both autosubmit parameters checked, it works.
Many thanks for this patch, I will let you know if it is stable for my project.
Comment #18
jeffschulerI was experiencing this same problem using DropzoneJS for a widget plugin.
I initially posted this in the DropzoneJS queue: #3118241: Automatically submit selection did not work.
@maticb, thank you. I recognize this is not a complete solution, but your patch in #14 is working for me, after ensuring I made the changes @Toki mentions in #17.
Comment #19
RenrhafUsing patch from #14 for a simple select and confirm use case. Works properly, thanks.
Comment #20
loze CreditAttribution: loze commentedPatch in #14 is working for me.
Comment #22
Dave ReidNeed to look into the failures, and I think this also needs to update the config schema, if we're adding an extra configuration key.
Comment #23
kazah CreditAttribution: kazah commentedWhy are we complicating this module so much?
Automatic filling of unnecessary tables.
Why not follow the example of the webform dropzone module?
Everything works intuitively there.
Comment #24
interlated CreditAttribution: interlated as a volunteer commentedMy goal was a single page, select single item by checklist. The patch applied. I still got the configuration exception.