mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18822: Fixing custom forms widgets on invalid entry
Work Item: 18822 --HG-- branch : 1.x
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
@@ -126,7 +127,14 @@ namespace Orchard.CustomForms.Controllers {
|
|||||||
_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)) {
|
||||||
|
Services.Notifier.Error(T(error));
|
||||||
|
}
|
||||||
|
if (returnUrl != null) {
|
||||||
|
return Redirect(returnUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
|
@@ -2,13 +2,12 @@
|
|||||||
@{
|
@{
|
||||||
ContentItem customForm = Model.ContentItem;
|
ContentItem customForm = Model.ContentItem;
|
||||||
string returnUrl = Model.ReturnUrl;
|
string returnUrl = Model.ReturnUrl;
|
||||||
var titlePart = customForm.As<Orchard.Core.Title.Models.TitlePart>();
|
|
||||||
|
|
||||||
// remove default Save/Publish buttons
|
// remove default Save/Publish buttons
|
||||||
Model.Zones["Sidebar"].Items.Clear();
|
Model.Zones["Sidebar"].Items.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Display(New.Parts_Title().ContentPart(titlePart).Title(titlePart.Title))
|
@Display(New.Parts_Title().Title(Html.ItemDisplayText(customForm)))
|
||||||
|
|
||||||
@using (Html.BeginFormAntiForgeryPost(returnUrl)) {
|
@using (Html.BeginFormAntiForgeryPost(returnUrl)) {
|
||||||
@Html.ValidationSummary()
|
@Html.ValidationSummary()
|
||||||
|
Reference in New Issue
Block a user