You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding validation errors to assets on upload no longer works as expected (ie the way it used to do in Craft 3.x).
Steps to reproduce
Add the following event handler to a module or a plugin:
Event::on(
Asset::class,
Model::EVENT_BEFORE_VALIDATE,
static function (ModelEvent $event) {
/** @var Asset $asset */
$asset = $event->sender;
$asset->addError('title', 'This asset does not validate!');
}
);
Upload an asset
Expected behavior
In Craft 3.x, this resulted in an alert popping up saying "Upload failed. The error message was: “This asset does not validate!”", and when clicking "Ok" the upload was aborted and you returned to the assets element index.
Actual behavior
In Craft 4.x, there is no error message, the status bar just stays on screen and nothing happens.
Two things I noticed:
In Craft 3, the response is a http 200, while in Craft 4 it's a 400
In Craft 3, a json object with one key, error, is returned, while in Craft 4 the key is called message.
Craft CMS version
4.0.1
PHP version
8.1.5
Operating system and version
macOS 11.2
Database type and version
MySQL 5.7.38
Image driver and version
Imagick 3.7.0 (ImageMagick 7.1.0-32)
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
What happened?
Description
Adding validation errors to assets on upload no longer works as expected (ie the way it used to do in Craft 3.x).
Steps to reproduce
Expected behavior
In Craft 3.x, this resulted in an alert popping up saying "Upload failed. The error message was: “This asset does not validate!”", and when clicking "Ok" the upload was aborted and you returned to the assets element index.
Actual behavior
In Craft 4.x, there is no error message, the status bar just stays on screen and nothing happens.
Two things I noticed:
error
, is returned, while in Craft 4 the key is calledmessage
.Craft CMS version
4.0.1
PHP version
8.1.5
Operating system and version
macOS 11.2
Database type and version
MySQL 5.7.38
Image driver and version
Imagick 3.7.0 (ImageMagick 7.1.0-32)
Installed plugins and versions
The text was updated successfully, but these errors were encountered: