mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
If no protector is set then skip the form field
This commit is contained in:
parent
05650e912d
commit
949ec2b359
@ -85,22 +85,25 @@ class FormSpamProtectionExtension extends Extension {
|
|||||||
|
|
||||||
// set custom mapping on this form
|
// set custom mapping on this form
|
||||||
$protector = self::get_protector($options);
|
$protector = self::get_protector($options);
|
||||||
|
|
||||||
if(isset($options['mapping'])) {
|
if(isset($options['mapping'])) {
|
||||||
$protector->setFieldMapping($options['mapping']);
|
$protector->setFieldMapping($options['mapping']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the form field
|
if($protector) {
|
||||||
if($field = $protector->getFormField($name, $title)) {
|
// add the form field
|
||||||
$field->setForm($this->owner);
|
if($field = $protector->getFormField($name, $title)) {
|
||||||
|
$field->setForm($this->owner);
|
||||||
|
|
||||||
// Add before field specified by insertBefore
|
// Add before field specified by insertBefore
|
||||||
$inserted = false;
|
$inserted = false;
|
||||||
if(!empty($options['insertBefore'])) {
|
if(!empty($options['insertBefore'])) {
|
||||||
$inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']);
|
$inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']);
|
||||||
}
|
}
|
||||||
if(!$inserted) {
|
if(!$inserted) {
|
||||||
// Add field to end if not added already
|
// Add field to end if not added already
|
||||||
$this->owner->Fields()->push($field);
|
$this->owner->Fields()->push($field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user