Optimizing client forms validation

This commit is contained in:
Sebastien Ros
2014-03-20 14:25:42 -07:00
parent a05a3d8dab
commit 878f45ad86
2 changed files with 3 additions and 5 deletions

View File

@@ -27,11 +27,9 @@ namespace Orchard.Comments.Controllers {
return this.RedirectLocal(returnUrl, "~/");
var comment = Services.ContentManager.New<CommentPart>("Comment");
Services.ContentManager.Create(comment, VersionOptions.Draft);
var editorShape = Services.ContentManager.UpdateEditor(comment, this);
if (!ModelState.IsValidField("Comments.Author")) {
Services.Notifier.Error(T("Name is mandatory and must have less than 255 chars"));
}
@@ -49,7 +47,6 @@ namespace Orchard.Comments.Controllers {
}
if (ModelState.IsValid) {
Services.ContentManager.Create(comment);
var commentPart = comment.As<CommentPart>();
@@ -58,6 +55,8 @@ namespace Orchard.Comments.Controllers {
Services.TransactionManager.Cancel();
return this.RedirectLocal(returnUrl, "~/");
}
Services.ContentManager.Create(comment.ContentItem, VersionOptions.Published);
var commentsPart = Services.ContentManager.Get(commentPart.CommentedOn).As<CommentsPart>();

View File

@@ -122,8 +122,6 @@ namespace Orchard.CustomForms.Controllers {
if (!Services.Authorizer.Authorize(Permissions.CreateSubmitPermission(customForm.ContentType), contentItem, T("Couldn't create content")))
return new HttpUnauthorizedResult();
if(customForm.SaveContentItem)
_contentManager.Create(contentItem, VersionOptions.Draft);
var model = _contentManager.UpdateEditor(contentItem, this);
@@ -164,6 +162,7 @@ namespace Orchard.CustomForms.Controllers {
// save the submitted form
if (customForm.SaveContentItem) {
_contentManager.Create(contentItem, VersionOptions.Draft);
conditionallyPublish(contentItem);
}