2007-10-22 01:05:46 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Allows visibility of a group of fields to be toggled using '+' and '-' icons
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-structural
|
2007-10-22 01:05:46 +02:00
|
|
|
*/
|
|
|
|
class ToggleCompositeField extends CompositeField {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var $headingLevel int
|
|
|
|
*/
|
|
|
|
public $headingLevel = 2;
|
|
|
|
|
2007-11-05 04:18:18 +01:00
|
|
|
function __construct($name, $title, $children) {
|
|
|
|
$this->name = $name;
|
2007-10-22 01:05:46 +02:00
|
|
|
$this->title = $title;
|
|
|
|
|
2009-06-19 04:38:33 +02:00
|
|
|
$this->startClosed(true);
|
2007-10-22 01:05:46 +02:00
|
|
|
|
|
|
|
parent::__construct($children);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function FieldHolder() {
|
2009-11-26 06:08:08 +01:00
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
ENHANCEMENT Introduced constants for system paths like /sapphire in preparation for a more flexible directory reorganisation. Instead of hardcoding your path, please use the following constants: BASE_PATH, BASE_URL, SAPPHIRE_DIR, SAPPHIRE_PATH, CMS_DIR, CMS_PATH, THIRDPARTY_DIR, THIRDPARTY_PATH, ASSETS_DIR, ASSETS_PATH, THEMES_DIR, THEMES_PATH
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63154 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-09-27 18:02:38 +02:00
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
2007-10-22 01:05:46 +02:00
|
|
|
|
|
|
|
return $this->renderWith("ToggleCompositeField");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the field should render open or closed by default.
|
|
|
|
*
|
|
|
|
* @param boolean
|
|
|
|
*/
|
|
|
|
public function startClosed($bool) {
|
|
|
|
($bool) ? $this->addExtraClass('startClosed') : $this->removeExtraClass('startClosed');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function HeadingLevel() {
|
|
|
|
return $this->headingLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Type() {
|
|
|
|
return ' toggleCompositeField';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|