SilverStripe\MathSpamProtection\MathSpamProtectorField
{@link FormField} for adding an optional maths protection question to a form.
Synopsis
class MathSpamProtectorField
extends TextField
{
- // members
- private static bool $enabled = true;
- private static $question_prefix;
- private static bool $allow_numeric_answer = true;
- // methods
- public void Field()
- public void FieldHolder()
- public string Title()
- public bool validate()
- public string getMathsQuestion()
- public bool isCorrectAnswer()
- public static string digit_to_word()
- public void Type()
Hierarchy
Extends
- SilverStripe\Forms\TextField
Members
private
- $allow_numeric_answer — SilverStripe\MathSpamProtection\bool
- $enabled — SilverStripe\MathSpamProtection\bool
- $question_prefix — string
Methods
public
- Field()
- FieldHolder()
- Title() — Returns the spam question
- Type()
- digit_to_word() — Helper method for converting digits to their equivalent english words
- getMathsQuestion() — Creates the question from random variables, which are also saved to the session.
- isCorrectAnswer() — Checks the given answer if it matches the addition of the saved session variables.
- validate() — Validates the value submitted by the user with the one saved into the {@link Session} and then notify callback object with the spam checking result.