From 14e768ca3256a0bf6d3c94450b4a062f9260766a Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Wed, 2 Mar 2016 11:51:13 -0500 Subject: [PATCH] Set Form for formField when validating When using EditableSpamProtectionField with UserForms 3.0, forms with a spam protector field (defined from FormSpamProtectorExtension), form submissions return an error: PHP Fatal error: Call to a member function FormName() on a non-object This because the exemplar formField generated by getFormField() does not have any connection to the particular form being submitted. This is fixed with a simple setForm() call in the validateField() function --- code/EditableSpamProtectionField.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/EditableSpamProtectionField.php b/code/EditableSpamProtectionField.php index 6d9f64c..24a89e7 100644 --- a/code/EditableSpamProtectionField.php +++ b/code/EditableSpamProtectionField.php @@ -142,7 +142,8 @@ if (class_exists('EditableFormField')) { public function validateField($data, $form) { $formField = $this->getFormField(); - + $formField->setForm($form); + if (isset($data[$this->Name])) { $formField->setValue($data[$this->Name]); }