Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Last active August 29, 2015 13:58
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/dc14bec928c0f4313b10 to your computer and use it in GitHub Desktop.
Save PetersonDave/dc14bec928c0f4313b10 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);
// lookup the actual form item
var formItem = Sitecore.Context.Database.Items[form.FormID];
// obtain the WFFM field
var countryField = formItem.Children[validatorSettings.CountryFieldId];
// get its required field value from the Checkbox field
Sitecore.Data.Fields.CheckboxField checkbox = countryField.Fields["Required"];
if (checkbox != null)
{
bool isRequired = checkbox.Checked;
// continue processing...
}
return base.OnServerValidate(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment