Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT Added FormField->setTemplate() and getTemplate(), using i…

…t in TabSet and other already template-driven FormField subclasses
  • Loading branch information...
commit 03547fb205e50cbaede2e3752702d8d1340832eb 1 parent 87bdb0d
@chillu chillu authored
View
4 forms/FileIFrameField.php
@@ -10,6 +10,8 @@
*/
class FileIFrameField extends FileField {
+ protected $template = 'FileIFrameField';
+
public static $allowed_actions = array (
'iframe',
'EditFileForm',
@@ -109,7 +111,7 @@ public function iframe() {
Requirements::css('sapphire/css/FileIFrameField.css');
- return $this->renderWith('FileIFrameField');
+ return $this->renderWith($this->template);
}
/**
View
21 forms/FormField.php
@@ -69,6 +69,11 @@ class FormField extends RequestHandler {
protected $disabled = false;
/**
+ * @var String
+ */
+ protected $template;
+
+ /**
* @var Custom Validation Message for the Field
*/
protected $customValidationMessage = "";
@@ -357,6 +362,22 @@ public function getCustomValidationMessage() {
}
/**
+ * Set name of template (without path or extension)
+ *
+ * @param String
+ */
+ function setTemplate($template) {
+ $this->template = $template;
+ }
+
+ /**
+ * @return String
+ */
+ function getTemplate() {
+ return $this->template;
+ }
+
+ /**
* Returns the form field - used by templates.
* Although FieldHolder is generally what is inserted into templates, all of the field holder
* templates make use of $Field. It's expected that FieldHolder will give you the "complete"
View
5 forms/SelectionGroup.php
@@ -7,6 +7,9 @@
* @subpackage fields-structural
*/
class SelectionGroup extends CompositeField {
+
+ protected $template = "SelectionGroup";
+
/**
* Create a new selection group.
* @param name The field name of the selection group.
@@ -83,7 +86,7 @@ function FieldHolder() {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
- return $this->renderWith("SelectionGroup");
+ return $this->renderWith($this->template);
}
}
View
4 forms/TabSet.php
@@ -27,6 +27,8 @@
*/
class TabSet extends CompositeField {
+ protected $template = "TabSetFieldHolder";
+
/**
* @param string $name Identifier
* @param string $title (Optional) Natural language title of the tabset
@@ -80,7 +82,7 @@ public function FieldHolder() {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js');
- return $this->renderWith("TabSetFieldHolder");
+ return $this->renderWith($this->template);
}
/**
View
4 forms/ToggleCompositeField.php
@@ -6,6 +6,8 @@
*/
class ToggleCompositeField extends CompositeField {
+ protected $template = "ToggleCompositeField";
+
/**
* @var $headingLevel int
*/
@@ -26,7 +28,7 @@ public function FieldHolder() {
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
- return $this->renderWith("ToggleCompositeField");
+ return $this->renderWith($this->template);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.