From 7ec8c205f1e02043bf748ad13d8ec272d407e1cc Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 12 Jun 2008 09:04:07 +0000 Subject: [PATCH] ENHANCEMENT Form->formTemplate() - allow rendering with Form subclass template MINOR code convention formatting git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@56142 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/Form.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/forms/Form.php b/forms/Form.php index 85f199be6..80303f8ea 100644 --- a/forms/Form.php +++ b/forms/Form.php @@ -265,7 +265,6 @@ class Form extends ViewableData { return $this->fields->dataFieldByName($name); } - /** * Return the form's action buttons - used by the templates * @@ -309,7 +308,6 @@ class Form extends ViewableData { $child = null; } } - } /** @@ -403,13 +401,13 @@ class Form extends ViewableData { * Returns the name of the form */ function FormName() { - return $this->class . '_' . str_replace('.','',$this->name); + return $this->class . '_' . str_replace('.', '', $this->name); } /** * @return string */ - function Name(){ + function Name() { return $this->name; } @@ -692,14 +690,19 @@ class Form extends ViewableData { } - /** * Return a rendered version of this form. + * + * This also allows for subclasses of Form to have their own template, + * falling back to 'Form' if it doesn't exist. + * * This is returned when you access a form as $FormObject rather than <% control FormObject %> */ function forTemplate() { - $form = $this->renderWith("Form"); - return $form; + return $this->renderWith(array( + $this->class, + 'Form' + )); } /**