2007-10-22 01:05:46 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Allows visibility of a group of fields to be toggled using '+' and '-' icons
|
2012-04-14 07:32:29 +02:00
|
|
|
*
|
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);
|
|
|
|
}
|
|
|
|
|
2012-04-11 08:07:55 +02:00
|
|
|
public function FieldHolder($properties = array()) {
|
2012-03-24 04:38:57 +01:00
|
|
|
Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/prototype/prototype.js");
|
|
|
|
Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/behaviour/behaviour.js");
|
|
|
|
Requirements::javascript(FRAMEWORK_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;
|
2012-04-14 07:32:29 +02:00
|
|
|
|
|
|
|
return $obj->renderWith($this->getTemplates());
|
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');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-04-14 07:32:29 +02:00
|
|
|
* @return string
|
2007-10-22 01:05:46 +02:00
|
|
|
*/
|
|
|
|
public function HeadingLevel() {
|
|
|
|
return $this->headingLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Type() {
|
|
|
|
return ' toggleCompositeField';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|