If I select multiple files to upload into multiple image or file field and one of the files won't pass validation it will break the widget display, though all valid files are uploaded. This also is broken for valid images.

image upload

When removing an image, this is also broken.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Issue summary: View changes
swentel’s picture

Version: 8.0-alpha7 » 8.x-dev

confirmed

plopesc’s picture

Title: Image not passing validation breaks widget » Files not passing validation breaks widget
Issue summary: View changes

Changing issue title and summary because I can reproduce the same problem in File widget, which is the Image's parent.

So I think the problem is in Filewidget instead of ImageWidget.

Regards

swentel’s picture

Title: Files not passing validation breaks widget » Files and image widgets completely broken
FileSize
50.47 KB

The widgets are broken, also if If you upload valid files. Also clicking on 'Remove' when going back to edit a node, is completely broken

swentel’s picture

Issue summary: View changes
swentel’s picture

Issue summary: View changes
swentel’s picture

Priority: Normal » Major

Also, this is really major

plopesc’s picture

After digging in this issue for a while, these are my conclusions:

  • IMO, there are two different problems here:
    • File widget is broken when you try to upload multiple files at the same time and not all are valids
    • Image widget is broken when you uploads more than one image, even uploaded one bye one. Also when trying to remove an item through the "Remove" button.
  • I've been debugging the FileWidget bug firstly given that ImageWidget extends it. I think that the bug is due to the managed_file form element validation. Given that the validation fails, widget FileWidget::formElement() and FileWidget::formMultipleElements() are not called and the correct values are not processed properly.

I'll try to work more on this along the next week, but not sure about the right way to fix this, because it looks related to the managed_file form element behavior. I'll also try to take a look to the ImageWidget bug.

Regards

webflo’s picture

Status: Active » Needs review
FileSize
2.3 KB

Looks like some ajax code from FileWidget::process is missing in ImageWidget::process

swentel’s picture

FileSize
643 bytes

Ah nice find! Updated patch. By calling the parent function, the change is even smaller.

I'm really not sure whether we need a test for this ..

swentel’s picture

FileSize
1.28 KB
1.9 KB

Now with tests. First one will have 2 failes, second one passes.

The last submitted patch, 11: 2172241-11-fail.patch, failed testing.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBM - nice catch, regression of recent core patch

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

  • Commit e9bb4a2 on 8.x by Dries:
    Issue #2172241 by swentel, webflo | ivanjaros: Fixed Files and image...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.