1

I have a custom plugin that checks for assets filename, and I'd like to prompt for confirmation like in the example below.

Is there a way to do that in Cp? If user clicks No then $event->isValid = false;

    Event::on(
        Asset::class,
        Asset::EVENT_BEFORE_SAVE,
        function(ModelEvent $event) {
            if ($event->isNew && $event->sender instanceof Asset) {
                $result = self::$plugin->checknameService->matchName($event->sender->filename);
                if (!empty($result)) {
                    // Prompt: "I don't like this asset name, are you sure? Yes / No"
                }
            }
        }
    );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.