I've spent hours trying to work this out to no avail.
I am using Orchard 1.6 source and DataAnnotations. My strings
are decorated with [Required]
as is my enum
. Yet, client validation will only work on the textboxes on my page (strings
), the enum
(radio button list) will not fire validation (nor does it show up as class="input-validation-error"
in the html source).
Here is my enum
:
public enum Referral
{
[Display(Name = "Google / Google+")]
Google,
[Display(Name = "Bing / Yahoo / Other Search Engine")]
OtherSearch,
[Display(Name = "LinkedIn")]
LinkedIn,
}
public class ReferralSelectorAttribute : SelectorAttribute
{
public override IEnumerable<SelectListItem> GetItems()
{
return Selector.GetItemsFromEnum<Referral>();
}
}
[Required(ErrorMessage = "Please select one referral option")]
[Display(Name = "How did you hear about us?",
Description = "Letting us know how you reached us helps us
to focus our advertising efforts and ultimately lowers costs")]
[ReferralSelector(BulkSelectionThreshold = 8)]
public virtual Referral? ReferralRadioButton { get; set; }
I am not sure why this is not firing. Any thoughts?
Note: I have tried just about everything I could find on the subject. I've registered the appropriate jquery scripts (validation, unobtrusive, etc.) with a special ResourceManifest.cs file. I've included it in my view. I've re-added model validation in a special Shell.cs file (IOrchardShellEvents or something).