mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-20 01:26:04 +02:00
API CHANGE Removed several unsed JavaScript globals: sprintf(), Number.prototype.CURRENCIES, Number.prototype.toCurrency(), String.prototype.ucfirst(), jQuery.fn.clearFields(), jQuery.fn.clearInputs() MINOR Removed prototype_improvements.js and jquery_improvements.js files, now contained in individual component code (or removed altogether)
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Allows visibility of a group of fields to be toggled using '+' and '-' icons
|
|
* @package forms
|
|
* @subpackage fields-structural
|
|
*/
|
|
class ToggleCompositeField extends CompositeField {
|
|
|
|
protected $template = "ToggleCompositeField";
|
|
|
|
/**
|
|
* @var $headingLevel int
|
|
*/
|
|
public $headingLevel = 2;
|
|
|
|
function __construct($name, $title, $children) {
|
|
$this->name = $name;
|
|
$this->title = $title;
|
|
|
|
$this->startClosed(true);
|
|
|
|
parent::__construct($children);
|
|
}
|
|
|
|
public function FieldHolder() {
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
|
|
|
return $this->renderWith($this->template);
|
|
}
|
|
|
|
/**
|
|
* 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';
|
|
}
|
|
}
|
|
|