Problem/Motivation
If you use the Lightning Media browser on a File or Image field, none of the field settings for validation are used. For example, if a File field is restricted to only allow .doc files, you can open the browser and upload any file type and embed it in the field. The same applies to max file size and image resolution field settings.
Proposed resolution
After #2761833: Widget context and validators not passed to Entity Browser element is committed, use the "upload_validators" Widget Context passed by \Drupal\entity_browser\Plugin\Field\FieldWidget\FileBrowserWidget to validate uploads before a Media Bundle is resolved. This will improve UX dramatically for people relying on File/Image field validations.
Remaining tasks
Wait for #2761833: Widget context and validators not passed to Entity Browser element to be committed and review/test this patch.
User interface changes
File and Image field settings will now be respected by the Lightning Media browser.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | lightning-widget-parent-validate.patch | 770 bytes | samuel.mortenson |
Comments
Comment #2
phenaproximaMost of this patch is obviated by https://github.com/acquia/lightning/pull/336, which pulls in #2761833: Widget context and validators not passed to Entity Browser element.
The only thing that PR doesn't contain is the call to parent::validate() in EntityFormProxy::validate(). This patch should be rerolled (and the issue title and summary updated) to only contain that line.
Comment #3
samuel.mortensonHere's a re-rolled patch with just the parent::validate call.
Comment #4
balsamaFixed as part of 556c7ec4e34604e8349b67254f54e35611a487cb