Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Created April 10, 2014 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PetersonDave/655404ca3ea36113a341 to your computer and use it in GitHub Desktop.
Save PetersonDave/655404ca3ea36113a341 to your computer and use it in GitHub Desktop.
protected override bool OnServerValidate(string value)
{
var validatorSettings = GetValidatorSettingsItem();
Sitecore.Diagnostics.Assert.IsNotNull(validatorSettings, ValidationSettingsItemMissingMessage + ValidationSettingsItem);
// obtain an instance of the SimpleForm
var form = WebUtil.GetParent<SimpleForm>(this);
// obtain an instance of our field
var countryField = (CountryDropDownList)WebUtil.FindFirstOrDefault(form, c => c is CountryDropDownList && string.Compare((c as CountryDropDownList).Result.FieldName, validatorSettings.CountryFieldName) == 0);
if (countryField != null)
{
// is the field required?
bool isRequired = countryField.Requred.Any();
// continue handling further processing here...
}
return base.OnServerValidate(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment