diff --git a/forms/FormField.php b/forms/FormField.php
index 8ffec80b1..000d409c7 100755
--- a/forms/FormField.php
+++ b/forms/FormField.php
@@ -405,6 +405,23 @@ class FormField extends RequestHandler {
// $MessageType is also used in {@link extraClass()} with a "holder-" prefix
$messageBlock = (!empty($Message)) ? "$Message" : "";
+ $values = array(
+ 'Title' => $Title,
+ 'Message' => $Message,
+ 'MessageType' => $MessageType,
+ 'RightTitle' => $RightTitle,
+ 'Type' => $Type,
+ 'extraClass' => $extraClass,
+ 'Name' => $Name,
+ 'Field' => $Field
+ );
+
+ // allow form field html to be decorated.
+ $subTemplates = $this->extend('updateFieldHolder', $values);
+ if($subTemplates && is_array($subTemplates)) {
+ return array_pop($subTemplates);
+ }
+
return <<$titleBlock
$Field
$rightTitleBlock$messageBlock
HTML;
diff --git a/tests/forms/FormFieldTest.php b/tests/forms/FormFieldTest.php
index 02b58a558..f656550d7 100644
--- a/tests/forms/FormFieldTest.php
+++ b/tests/forms/FormFieldTest.php
@@ -85,5 +85,30 @@ class FormFieldTest extends SapphireTest {
}
}
+ /**
+ * Test to ensure that subclassing the form field FieldHolder updates the html
+ * the field produces
+ */
+ function testCustomFieldOverridesTemplate() {
+ $orignal = new TextField('Name');
+ $orignalHTML = $orignal->FieldHolder();
+
+ Object::add_extension('FormField', 'FormFieldTest_CustomFormSubclass');
+ $textField = new TextField('Name');
+ $newHTML = $textField->FieldHolder();
+
+ $this->assertNotSame($orignalHTML, $newHTML);
+ $this->assertSame($newHTML, '');
+ }
+}
+
+class FormFieldTest_CustomFormSubclass extends Extension implements TestOnly {
+
+ function updateFieldHolder(array $array) {
+ extract($array);
+ return <<
+HTML;
+ }
}
?>
\ No newline at end of file