Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Last active December 25, 2015 01:29
Show Gist options
  • Save PetersonDave/6895451 to your computer and use it in GitHub Desktop.
Save PetersonDave/6895451 to your computer and use it in GitHub Desktop.
Example of how to access a field on a WFFM form outside the validator's field context.
protected override bool OnServerValidate(string value)
{
// get the form
var form = WebUtil.GetParent<SimpleForm>(this);
// find another field within our form
var field = (SingleLineText)WebUtil.FindFirstOrDefault(form, c => c is SingleLineText && (c as SingleLineText).Result.FieldName == "City");
// compare values between this field (State) and the value of a different field (City)
bool isBoston = field != null && field.Result.Value.ToString() == "Boston";
bool isMassachusetts = !string.IsNullOrEmpty(value) && value == "MA";
return isBoston && isMassachusetts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment