Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Charlene 9 posts 77 karma points
    Sep 29, 2021 @ 13:58
    Charlene
    0

    Drag and drop Media doesn't ask for the required field.

    I have edited the Image data type to have a mandatory field called 'title'. When the media is created using the create Button - It asks for the title field.

    enter image description here enter image description here

    However - if the drag and drop functionality is used - It uploads the image without validating the required title field.

    Is there a way to make sure the image always validates the required fields?

  • MK 428 posts 904 karma points
    19 days ago
    MK
    0

    Hi Charlene,

    Did you manage to sort this out?

    Thanks

    mk

  • MK 428 posts 904 karma points
    1 week ago
    MK
    0

    Hi, I did the following. You can alter this as per your requirements.

    app.run(function (eventsService, mediaResource, editorService) {
        var unsubscribe = eventsService.on("dialogs.mediaPicker.select", function (event, args) {
            mediaResource.getById(args.id).then(function (mediaEntity) {
                const propValid = mediaEntity.properties.some(function (element) {
                    return element.validation.mandatory === true && element.value === '';
                });
                if (propValid) {
                    const mediaEditor = {
                        id: args.id,
                        submit: () => {
                            editorService.close();
                        },
                        close: () => {
                            editorService.close();
                        }
                    };
                    editorService.mediaEditor(mediaEditor);
                }
            });
        });
    });
    

    mk

Please Sign in or register to post replies

Write your reply to:

Draft