diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs index 77eaae0b6..4687f711d 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs @@ -106,7 +106,11 @@ namespace Orchard.Comments.Drivers { var currentUser = workContext.CurrentUser; part.UserName = (currentUser != null ? currentUser.UserName : null); - if (currentUser != null) part.Author = currentUser.UserName; + if (currentUser != null) + part.Author = currentUser.UserName; + else if (string.IsNullOrWhiteSpace(part.Author)) { + updater.AddModelError("Comments.Author", T("Name is mandatory")); + } var moderateComments = workContext.CurrentSite.As().ModerateComments; part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved; diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs index 79b3d126f..4ef90c4ff 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs @@ -12,7 +12,7 @@ namespace Orchard.Comments.Models { public LazyField CommentedOnContentItemField { get { return _commentedOnContentItem; } } public LazyField CommentedOnContentItemMetadataField { get { return _commentedOnContentItemMetadata; } } - [Required, StringLength(255)] + [StringLength(255)] public string Author { get { return Record.Author; } set { Record.Author = value; } @@ -31,7 +31,7 @@ namespace Orchard.Comments.Models { set { Record.UserName = value; } } - [Required, RegularExpression(@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?
  • @Html.LabelFor(m => m.Author, T("Name")) - @Html.TextBoxFor(m => m.Author, new { required = "required" }) + @Html.TextBoxFor(m => m.Author)
  • @Html.LabelFor(m => m.Email, T("Email")) - @Html.TextBoxFor(m => m.Email, new { required = "required" }) + @Html.TextBoxFor(m => m.Email)
  • @Html.LabelFor(m => m.SiteName, T("Url")) @@ -21,7 +21,7 @@ } else { - @Html.Hidden("Author", WorkContext.CurrentUser.UserName ?? "") + @Html.Hidden("Name", WorkContext.CurrentUser.UserName ?? "") @Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "") }