We have a fairly straight forward entity browser configured that has the the Entity Form on the first tab and a media library view on the second one. When we switch from the entity form tab to the view tab it throws the following error:

TypeError: Argument 1 passed to file_validate() must implement interface Drupal\file\FileInterface, instance of Drupal\media\Entity\Media given, called in entity_browser/src/Plugin/EntityBrowser/WidgetValidation/File.php on line 34 in file_validate() (line 323 of core/modules/file/file.module).

It seems like clicking off the form to the other tab triggers the validation logic on the entity form, but because nothing has been added to that form it results in the above.

CommentFileSizeAuthor
#2 entity_browser-n3122383-2.patch1.34 KBdamienmckenna

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Version: 8.x-2.4 » 8.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.34 KB

A stopgap to stop our site from breaking when folks try to use the media browser :)

akalata’s picture

berdir’s picture

> but because nothing has been added to that form it results in the above

It's not empty though. It's a media entity, while that is for some arcane reason trying to validate a file. Which it simply shouldn't do.

chris matthews’s picture

Came across this issue on a site today. Can anyone comment as to whether or not the patch in this issue is best, or the one in #2930677: Validate widget entity type and bundles?

chris matthews’s picture

I applied the patch in #2, but I'm still getting:

The entity must be of type file.

nelo_drup’s picture

@Chris Matthews Same error

benstallings’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2930677: Validate widget entity type and bundles

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.