mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
b1d2e3906b
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47766 467b73ca-7a2a-4603-9d3b-597d59a354a9
40 lines
1003 B
PHP
Executable File
40 lines
1003 B
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package forms
|
|
* @subpackage fields-dataless
|
|
*/
|
|
|
|
/**
|
|
* A {@link LabelField} that lets you give it a name; makes it easier to delete ;)
|
|
* @package forms
|
|
* @subpackage fields-dataless
|
|
*/
|
|
class NamedLabelField extends LabelField {
|
|
protected $className;
|
|
protected $allowHTML;
|
|
protected $labelName;
|
|
|
|
/**
|
|
* Create a new label.
|
|
* @param title The label itslef
|
|
* @param class An HTML class to apply to the label.
|
|
*/
|
|
function __construct($name, $title, $className = "", $allowHTML = false, $form = null) {
|
|
$this->labelName = $name;
|
|
parent::__construct($title, $className, $allowHTML, $form);
|
|
}
|
|
|
|
/**
|
|
* Returns a label containing the title, and an HTML class if given.
|
|
*/
|
|
function Field() {
|
|
if($this->className) $classClause = " class=\"$this->className\"";
|
|
return "<label id=\"" . $this->id() . "\"$classClause>" . ($this->allowHTML ? $this->title : htmlentities($this->title)) . "</label>";
|
|
}
|
|
|
|
function id() {
|
|
return parent::id() . $this->labelName;
|
|
}
|
|
}
|
|
?>
|