Quantcast
Viewing all articles
Browse latest Browse all 294646

Media library remove button triggers field constraint validation

Problem/Motivation

We have the following use case:

  • Node
    • Field "Media"
      • Constraint (that checks for a value in media entity)

The constraint gets the media entity and checks for a given field value. If this value is set validation runs through if not a violation is added.

Steps to reproduce

Config / Code

  • Create a node type X with an entity reference field to a media bundle.
  • Use media library as field widget.
  • Add a constraint on the field that dives into media entity. (Via hook_entity_bundle_field_info_alter())

Content

  • Create node of type X.
  • Add a media entity that violates your constraint.
  • Try saving the node. -> Constraint should not allow saving.
  • Try removing the media entity. -> Constraint falsely doesn't allow removal.
  • Deadlock.

Proposed resolution

In MediaLibraryWidget.php:413 do not limit validation errors to parent but instead set to empty array.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294646

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>