Problem/Motivation

Field widget + entity browser with view widget with "automatically submit" option throws exception.

ConfigException should be validated during configuration

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

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GiorgosK created an issue. See original summary.

GiorgosK’s picture

here is screenshot of setting and the error

slashrsm’s picture

Category: Bug report » Support request
Issue tags: +D8Media

Which selection display are you using? This feature (Automatically submit selection) can currently work only with the Multi step selection display.

marcoscano’s picture

Status: Active » Postponed (maintainer needs more info)

Postponing until we have more info on how to reproduce.

Please feel free to re-open when that is the case.

Thanks!

bceyssens’s picture

Status: Postponed (maintainer needs more info) » Active

We 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.

juliencarnot’s picture

Same 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)...

rwam’s picture

This feature (Automatically submit selection) can currently work only with the Multi step selection display.

Sorry, it doesn't. If I check this option I get an AjaxError:

AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /entity-browser/modal/multiple_image_browser?uuid=3f75a75c37e965fa403eaccb78d2ce0970e2b8f0&original_path=/media/373/edit&ajax_form=1
StatusText: Not Found
ResponseText: {"message":""}

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

glass.dimly’s picture

My use case here is a single-select field. Multi-step as well as the selection button allow for the selection of multiple items.

alienzed’s picture

no fix yet?

oknate’s picture

Version: 8.x-1.0-rc1 » 8.x-2.x-dev
Assigned: Unassigned » oknate

I 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.

    if ($widget->requiresJsCommands() && !$selectionDisplay->supportsJsCommands()) {
        throw new ConfigException('Used entity browser selection display cannot work in combination with settings defined for used selection widget.');
      }
oknate’s picture

Issue summary: View changes
oknate’s picture

Issue summary: View changes
FileSize
276.66 KB
oknate’s picture

Issue summary: View changes
maticb’s picture

This 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:

<?php
  $ajax->addCommand(
        new InvokeCommand('.entity-browser-use-selected.button--primary', 'click')
      );
?>

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.

Toki’s picture

Working 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?

maticb’s picture

@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?

Toki’s picture

@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.

jeffschuler’s picture

I 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.

Renrhaf’s picture

Using patch from #14 for a simple select and confirm use case. Works properly, thanks.

loze’s picture

Status: Active » Needs review

Patch in #14 is working for me.

Status: Needs review » Needs work
Dave Reid’s picture

Need to look into the failures, and I think this also needs to update the config schema, if we're adding an extra configuration key.

kazah’s picture

Why 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.

interlated’s picture

My goal was a single page, select single item by checklist. The patch applied. I still got the configuration exception.

NigelCunningham made their first commit to this issue’s fork.