mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
4a5d9b03f8
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@39001 467b73ca-7a2a-4603-9d3b-597d59a354a9
31 lines
794 B
PHP
Executable File
31 lines
794 B
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Simple label tag.
|
|
* This can be used to add extra text in your forms.
|
|
*/
|
|
class LabelField extends DatalessField {
|
|
protected $className;
|
|
protected $allowHTML;
|
|
|
|
/**
|
|
* Create a new label.
|
|
* @param title The label itslef
|
|
* @param class An HTML class to apply to the label.
|
|
*/
|
|
function __construct($title, $className = "", $allowHTML = false, $form = null) {
|
|
$this->className = $className;
|
|
$this->allowHTML = $allowHTML;
|
|
|
|
parent::__construct(null, $title, null, $form);
|
|
}
|
|
|
|
/**
|
|
* Returns a label containing the title, and an HTML class if given.
|
|
*/
|
|
function Field() {
|
|
$classClause = $this->className ? " class=\"$this->className\"" : '';
|
|
return "<label$classClause>" . ($this->allowHTML ? $this->title : htmlentities($this->title)) . "</label>";
|
|
}
|
|
}
|
|
?>
|