Changeset #5459 "#17754: Localizing validation attributes" caused client
validation fail. The problem is that unobtrusive html data attributes
are no longer rendered in html since Orchard 1.3.
Added lines in OrchardStarter.cs in 5459
// Register localized data annotations
ModelValidatorProviders.Providers.Clear();
ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider());
caused this. Here is the test.
ValidationController.cs
namespace Validation.Controllers
{
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Orchard.Themes;
[Themed]
public class ValidationController : Controller
{
public ActionResult Index()
{
return View(new ValidationEditModel());
}
}
public class ValidationEditModel
{
[Required]
public string Name { get; set; }
}
}
Index.cshtml
@using Validation.Controllers
@model ValidationEditModel
@{
HtmlHelper.ClientValidationEnabled = true;
HtmlHelper.UnobtrusiveJavaScriptEnabled = true;
}
@using (Html.BeginForm())
{
@Html.EditorForModel()
}
Html rendered in Orchard 1.2
<input class="text-box single-line" data-val="true" data-val-required="The Name field is required." id="Name" name="Name" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true">
Html rendered in Orchard 1.3
<input class="text-box single-line" id="Name" name="Name" type="text" value="" />