Remove extra conditional by storing the field name in a private static

This commit is contained in:
James Ellis 2017-08-24 04:17:12 +00:00
parent 82271cb1b2
commit e45082893d
1 changed files with 10 additions and 3 deletions

View File

@ -41,6 +41,15 @@ class FormSpamProtectionExtension extends Extension
'authorId'
);
/**
* @config
*
* The field name to use for the {@link SpamProtector} {@link FormField}
*
* @var string $spam_protector
*/
private static $field_name = "Captcha";
/**
* Instantiate a SpamProtector instance
*
@ -74,10 +83,8 @@ class FormSpamProtectionExtension extends Extension
// captcha form field name (must be unique)
if (isset($options['name'])) {
$name = $options['name'];
} else if($field_name = Config::inst()->get('FormSpamProtectionExtension', 'field_name')) {
$name = $field_name;
} else {
$name = 'Captcha';
$name = Config::inst()->get('FormSpamProtectionExtension', 'field_name');
}
// captcha field title