mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
Merge pull request #25 from silverstripe-rebelalliance/westpac
Fix for compatibility with userforms 3.0
This commit is contained in:
commit
09ec50bf2d
@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editable Spam Protecter Field. Used with the User Defined Forms module (if
|
* Editable Spam Protecter Field. Used with the User Defined Forms module (if
|
||||||
* installed) to allow the user to have captcha fields with their custom forms
|
* installed) to allow the user to have captcha fields with their custom forms
|
||||||
*
|
*
|
||||||
* @package spamprotection
|
* @package spamprotection
|
||||||
*/
|
*/
|
||||||
if(class_exists('EditableFormField')) {
|
if(class_exists('EditableFormField')) {
|
||||||
|
|
||||||
class EditableSpamProtectionField extends EditableFormField {
|
class EditableSpamProtectionField extends EditableFormField {
|
||||||
|
|
||||||
private static $singular_name = 'Spam Protection Field';
|
private static $singular_name = 'Spam Protection Field';
|
||||||
|
|
||||||
private static $plural_name = 'Spam Protection Fields';
|
private static $plural_name = 'Spam Protection Fields';
|
||||||
/**
|
/**
|
||||||
* Fields to include spam detection for
|
* Fields to include spam detection for
|
||||||
@ -24,7 +24,7 @@ if(class_exists('EditableFormField')) {
|
|||||||
'EditableTextField',
|
'EditableTextField',
|
||||||
'EditableNumericField'
|
'EditableNumericField'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
// Get protector
|
// Get protector
|
||||||
$protector = FormSpamProtectionExtension::get_protector();
|
$protector = FormSpamProtectionExtension::get_protector();
|
||||||
@ -72,11 +72,11 @@ if(class_exists('EditableFormField')) {
|
|||||||
// Get protector
|
// Get protector
|
||||||
$protector = FormSpamProtectionExtension::get_protector();
|
$protector = FormSpamProtectionExtension::get_protector();
|
||||||
if (!$protector) return $fields;
|
if (!$protector) return $fields;
|
||||||
|
|
||||||
if ($this->Parent()->Fields() instanceof UnsavedRelationList) {
|
if ($this->Parent()->Fields() instanceof UnsavedRelationList) {
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each other text field in this group can be assigned a field mapping
|
// Each other text field in this group can be assigned a field mapping
|
||||||
$mapGroup = FieldGroup::create(_t(
|
$mapGroup = FieldGroup::create(_t(
|
||||||
'EditableSpamProtectionField.SPAMFIELDMAPPING',
|
'EditableSpamProtectionField.SPAMFIELDMAPPING',
|
||||||
@ -104,10 +104,17 @@ if(class_exists('EditableFormField')) {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateField($data, $form) {
|
||||||
|
$formField = $this->getFormField();
|
||||||
|
if (!$formField->validate($form->getValidator())) {
|
||||||
|
$form->addErrorMessage($this->Name, $this->getErrorMessage()->HTML(), 'error', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getFieldValidationOptions() {
|
public function getFieldValidationOptions() {
|
||||||
return new FieldList();
|
return new FieldList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequired() {
|
public function getRequired() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -115,7 +122,7 @@ if(class_exists('EditableFormField')) {
|
|||||||
public function getIcon() {
|
public function getIcon() {
|
||||||
return 'spamprotection/images/' . strtolower($this->class) . '.png';
|
return 'spamprotection/images/' . strtolower($this->class) . '.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showInReports() {
|
public function showInReports() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user