mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Encoding error messages for custom forms widgets.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
@@ -126,14 +127,14 @@ namespace Orchard.CustomForms.Controllers {
|
|||||||
_contentManager.Create(contentItem, VersionOptions.Draft);
|
_contentManager.Create(contentItem, VersionOptions.Draft);
|
||||||
|
|
||||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
_transactionManager.Cancel();
|
_transactionManager.Cancel();
|
||||||
|
|
||||||
// if custom form is inside a widget, we display the form itself
|
// if custom form is inside a widget, we display the form itself
|
||||||
if (form.ContentType == "CustomFormWidget") {
|
if (form.ContentType == "CustomFormWidget") {
|
||||||
foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)) {
|
foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)) {
|
||||||
Services.Notifier.Error(T(error));
|
Services.Notifier.Error(new LocalizedString(HttpUtility.HtmlEncode(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the updated editor shape into TempData to survive a redirection and keep the edited values
|
// save the updated editor shape into TempData to survive a redirection and keep the edited values
|
||||||
|
|||||||
Reference in New Issue
Block a user