2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
|
2008-01-09 05:18:36 +01:00
|
|
|
/**
|
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-dataless
|
|
|
|
*/
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
|
|
|
* A {@link LabelField} that lets you give it a name; makes it easier to delete ;)
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-dataless
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|