#18822: Fixing custom forms widgets on invalid entry

Work Item: 18822

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-09-28 14:08:26 -07:00
parent ba50ceee3c
commit 57c9ed5d8c
2 changed files with 10 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
using Orchard.ContentManagement;
@@ -126,7 +127,14 @@ namespace Orchard.CustomForms.Controllers {
_transactionManager.Cancel();
// 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.
return View((object)model);

View File

@@ -2,13 +2,12 @@
@{
ContentItem customForm = Model.ContentItem;
string returnUrl = Model.ReturnUrl;
var titlePart = customForm.As<Orchard.Core.Title.Models.TitlePart>();
// remove default Save/Publish buttons
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)) {
@Html.ValidationSummary()