2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-10 16:03:34 +01:00
|
|
|
* Simple label tag. This can be used to add extra text in your forms.
|
|
|
|
* Consider using a {@link ReadonlyField} if you need to display a label
|
|
|
|
* AND a value.
|
|
|
|
*
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-dataless
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class LabelField extends DatalessField {
|
|
|
|
|
|
|
|
/**
|
2008-10-16 15:26:25 +02:00
|
|
|
* @param string $name
|
|
|
|
* @param string $title
|
|
|
|
* @param string $className (Deprecated: use addExtraClass())
|
|
|
|
* @param bool $allowHTML (Deprecated: use setAllowHTML())
|
|
|
|
* @param Form $form
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2008-10-16 15:26:25 +02:00
|
|
|
function __construct($name, $title, $className = null, $allowHTML = false, $form = null) {
|
|
|
|
// legacy handling for old parameters: $title, $heading, ...
|
|
|
|
// instead of new handling: $name, $title, $heading, ...
|
|
|
|
$args = func_get_args();
|
|
|
|
if(!isset($args[1])) {
|
|
|
|
$title = (isset($args[0])) ? $args[0] : null;
|
|
|
|
$name = $title;
|
|
|
|
$classname = (isset($args[1])) ? $args[1] : null;
|
|
|
|
$allowHTML = (isset($args[2])) ? $args[2] : null;
|
|
|
|
$form = (isset($args[3])) ? $args[3] : null;
|
|
|
|
}
|
|
|
|
|
2009-12-15 01:07:00 +01:00
|
|
|
parent::__construct($name, $title, null, $allowHTML, $form);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a label containing the title, and an HTML class if given.
|
|
|
|
*/
|
|
|
|
function Field() {
|
2008-10-16 15:26:25 +02:00
|
|
|
$attributes = array(
|
|
|
|
'class' => $this->extraClass(),
|
2010-01-15 03:23:03 +01:00
|
|
|
'id' => $this->id()
|
2008-10-16 15:26:25 +02:00
|
|
|
);
|
|
|
|
return $this->createTag(
|
|
|
|
'label',
|
|
|
|
$attributes,
|
|
|
|
($this->getAllowHTML() ? $this->title : htmlentities($this->title))
|
|
|
|
);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|