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;
|
|
|
|
|
|
|
|
$this->startClosed(true);
|
|
|
|
|
|
|
|
parent::__construct($children);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function FieldHolder() {
|
|
|
|
Requirements::javascript("jsparty/prototype.js");
|
|
|
|
Requirements::javascript("jsparty/behaviour.js");
|
|
|
|
Requirements::javascript("jsparty/prototype_improvements.js");
|
|
|
|
Requirements::javascript("sapphire/javascript/ToggleCompositeField.js");
|
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|