mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Optimizing client forms validation
This commit is contained in:
@@ -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>();
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user