diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index bf556ced0f2..1f87de692aa 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -12,6 +12,7 @@ - Fixed a bug where the `ContentBehaviour` and `ElementQueryBehavior` classes could be missing some field properties. ([#3400](https://github.com/craftcms/cms/issues/3400)) - Fixed a bug where some fields within Matrix fields could lose their values after enabling the “Manage blocks on a per-site basis” setting. ([verbb/super-table/203](https://github.com/verbb/super-table/issues/203)) - Fixed a bug where HTML Purifier wasn’t being initialized with HTML 5 element support. +- Fixed a bug where it was possible to save Assets fields with the “Restrict allowed file types?” setting enabled, but no specific file types selected. ([#3410](https://github.com/craftcms/cms/issues/3410)) ## 3.0.28 - 2018-10-23 diff --git a/src/fields/Assets.php b/src/fields/Assets.php index feb1305e2db..fa876e14c70 100644 --- a/src/fields/Assets.php +++ b/src/fields/Assets.php @@ -121,6 +121,20 @@ public function init() $this->inputJsClass = 'Craft.AssetSelectInput'; } + /** + * @inheritdoc + */ + public function rules() + { + $rules = parent::rules(); + + $rules[] = [['allowedKinds'], 'required', 'when' => function(self $field): bool { + return (bool)$field->restrictFiles; + }]; + + return $rules; + } + /** * @inheritdoc */ diff --git a/src/templates/_components/fieldtypes/Assets/settings.html b/src/templates/_components/fieldtypes/Assets/settings.html index 28fce6c86eb..09c33db73d2 100644 --- a/src/templates/_components/fieldtypes/Assets/settings.html +++ b/src/templates/_components/fieldtypes/Assets/settings.html @@ -92,6 +92,7 @@ checked: (option.value in field.allowedKinds) }) }} {% endfor %} + {{ forms.errorList(field.getErrors('allowedKinds')) }} {% endblock %}