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 {
|
|
|
|
|
2011-04-16 05:09:30 +02:00
|
|
|
protected $template = "ToggleCompositeField";
|
|
|
|
|
2007-10-22 01:05:46 +02:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
|
2012-04-11 08:07:55 +02:00
|
|
|
public function FieldHolder($properties = array()) {
|
2009-11-21 03:29:59 +01:00
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
|
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.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
|
|
|
|
2012-04-11 08:07:55 +02:00
|
|
|
$obj = $properties ? $this->customise($properties) : $this;
|
|
|
|
return $obj->renderWith($this->template);
|
2007-10-22 01:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|