mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Added FormField->setTemplate() and getTemplate(), using it in TabSet and other already template-driven FormField subclasses
This commit is contained in:
parent
87bdb0d3d1
commit
03547fb205
@ -10,6 +10,8 @@
|
|||||||
*/
|
*/
|
||||||
class FileIFrameField extends FileField {
|
class FileIFrameField extends FileField {
|
||||||
|
|
||||||
|
protected $template = 'FileIFrameField';
|
||||||
|
|
||||||
public static $allowed_actions = array (
|
public static $allowed_actions = array (
|
||||||
'iframe',
|
'iframe',
|
||||||
'EditFileForm',
|
'EditFileForm',
|
||||||
@ -109,7 +111,7 @@ class FileIFrameField extends FileField {
|
|||||||
|
|
||||||
Requirements::css('sapphire/css/FileIFrameField.css');
|
Requirements::css('sapphire/css/FileIFrameField.css');
|
||||||
|
|
||||||
return $this->renderWith('FileIFrameField');
|
return $this->renderWith($this->template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +68,11 @@ class FormField extends RequestHandler {
|
|||||||
*/
|
*/
|
||||||
protected $disabled = false;
|
protected $disabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var String
|
||||||
|
*/
|
||||||
|
protected $template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Custom Validation Message for the Field
|
* @var Custom Validation Message for the Field
|
||||||
*/
|
*/
|
||||||
@ -356,6 +361,22 @@ class FormField extends RequestHandler {
|
|||||||
return $this->customValidationMessage;
|
return $this->customValidationMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Returns the form field - used by templates.
|
||||||
* Although FieldHolder is generally what is inserted into templates, all of the field holder
|
* Although FieldHolder is generally what is inserted into templates, all of the field holder
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
* @subpackage fields-structural
|
* @subpackage fields-structural
|
||||||
*/
|
*/
|
||||||
class SelectionGroup extends CompositeField {
|
class SelectionGroup extends CompositeField {
|
||||||
|
|
||||||
|
protected $template = "SelectionGroup";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new selection group.
|
* Create a new selection group.
|
||||||
* @param name The field name of the selection group.
|
* @param name The field name of the selection group.
|
||||||
@ -83,7 +86,7 @@ class SelectionGroup extends CompositeField {
|
|||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
|
||||||
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
|
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
|
||||||
|
|
||||||
return $this->renderWith("SelectionGroup");
|
return $this->renderWith($this->template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
class TabSet extends CompositeField {
|
class TabSet extends CompositeField {
|
||||||
|
|
||||||
|
protected $template = "TabSetFieldHolder";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name Identifier
|
* @param string $name Identifier
|
||||||
* @param string $title (Optional) Natural language title of the tabset
|
* @param string $title (Optional) Natural language title of the tabset
|
||||||
@ -80,7 +82,7 @@ class TabSet extends CompositeField {
|
|||||||
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js');
|
||||||
|
|
||||||
return $this->renderWith("TabSetFieldHolder");
|
return $this->renderWith($this->template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
class ToggleCompositeField extends CompositeField {
|
class ToggleCompositeField extends CompositeField {
|
||||||
|
|
||||||
|
protected $template = "ToggleCompositeField";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $headingLevel int
|
* @var $headingLevel int
|
||||||
*/
|
*/
|
||||||
@ -26,7 +28,7 @@ class ToggleCompositeField extends CompositeField {
|
|||||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
||||||
|
|
||||||
return $this->renderWith("ToggleCompositeField");
|
return $this->renderWith($this->template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user