diff --git a/CHANGELOG.md b/CHANGELOG.md index aecd9db096b..facb46c3eb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed a SQL error that occurred when running the `db/convert-charset` command if there were any custom database views or sequences. ([#15598](https://github.com/craftcms/cms/issues/15598)) - Fixed a bug where `craft\helpers\Db::supportsTimeZones()` could return `false` on databases that supported time zone conversion. ([#15592](https://github.com/craftcms/cms/issues/15592)) +- Fixed a bug where Assets fields were validating settings that weren’t applicable depending on the “Restrict assets to a single location” setting. ([#15545](https://github.com/craftcms/cms/issues/15545)) ## 4.11.5 - 2024-08-26 diff --git a/src/fields/Assets.php b/src/fields/Assets.php index 2ef87beee4c..c5f1754b071 100644 --- a/src/fields/Assets.php +++ b/src/fields/Assets.php @@ -242,11 +242,19 @@ protected function defineRules(): array [ 'sources', 'defaultUploadLocationSource', - 'restrictedLocationSource', 'defaultUploadLocationSubpath', + ], + 'validateNotTempVolume', + 'when' => fn() => !$this->restrictLocation, + ]; + + $rules[] = [ + [ + 'restrictedLocationSource', 'restrictedLocationSubpath', ], 'validateNotTempVolume', + 'when' => fn() => $this->restrictLocation, ]; $rules[] = [['previewMode'], 'in', 'range' => [self::PREVIEW_MODE_FULL, self::PREVIEW_MODE_THUMBS], 'skipOnEmpty' => false];