Fixed issue with model state marked as invalid on the entire model, where we handle it for each item separately

This commit is contained in:
Bjarke Berg
2021-08-11 15:43:41 +02:00
parent dfa76af4d6
commit c5e882680b
2 changed files with 7 additions and 1 deletions

View File

@@ -913,9 +913,9 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
v.Notifications.AddRange(n.Notifications);
}
//lastly, if it is not valid, add the model state to the outgoing object and throw a 400
HandleInvalidModelState(display, cultureForInvariantErrors);
//lastly, if it is not valid, add the model state to the outgoing object and throw a 400
if (!ModelState.IsValid)
{
return ValidationProblem(display, ModelState);

View File

@@ -68,6 +68,12 @@ namespace Umbraco.Cms.Web.BackOffice.Filters
var model = (ContentItemSave) context.ActionArguments["contentItem"];
var contentItemValidator = new ContentSaveModelValidator(_loggerFactory.CreateLogger<ContentSaveModelValidator>(), _propertyValidationService);
if (context.ModelState.ContainsKey("contentItem"))
{
// if the entire model is marked as error, remove it, we handle everything separately
context.ModelState.Remove("contentItem");
}
if (!ValidateAtLeastOneVariantIsBeingSaved(model, context)) return;
if (!contentItemValidator.ValidateExistingContent(model, context)) return;
if (!await ValidateUserAccessAsync(model, context)) return;