#19732: Retaining update editor for custom forms widgets

Work Item: 19732

--HG--
branch : 1.x
This commit is contained in:
GQAdonis
2013-07-15 11:50:27 -07:00
parent bade9fe4ce
commit 7e4333722e
2 changed files with 13 additions and 6 deletions

View File

@@ -130,7 +130,10 @@ namespace Orchard.CustomForms.Controllers {
if (form.ContentType == "CustomFormWidget") {
foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)) {
Services.Notifier.Error(T(error));
}
}
// save the updated editor shape into TempData to survive a redirection and keep the edited values
TempData["CustomFormWidget.InvalidCustomFormState"] = model;
if (returnUrl != null) {
return this.RedirectLocal(returnUrl);

View File

@@ -1,14 +1,18 @@
@using Orchard.ContentManagement;
@{
@{
dynamic editor = Model.Editor;
if (TempData.ContainsKey("CustomFormWidget.InvalidCustomFormState")) {
editor = TempData["CustomFormWidget.InvalidCustomFormState"];
}
// remove default Save/Publish buttons
Model.Editor.Zones["Sidebar"].Items.Clear();
editor.Zones["Sidebar"].Items.Clear();
}
@using (Html.BeginFormAntiForgeryPost(Url.Action("Create", "Item", new { area = "Orchard.CustomForms", id = Model.ContentItem.Id }))) {
@Html.ValidationSummary()
// Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type
@Display(Model.Editor)
@Display(editor)
@Html.Hidden("returnUrl", Request.RawUrl);