1 <?php
2 /**
3 * Abstract class for all fields without data.
4 * Labels, headings and the like should extend from this.
5 *
6 * @package forms
7 * @subpackage fields-dataless
8 */
9 class DatalessField extends FormField {
10
11 /**
12 * @var bool $allowHTML
13 */
14 protected $allowHTML;
15
16 /**
17 * @param string $name
18 * @param string $title The label itslef
19 * @param string $class An HTML class to apply to the label (Deprecated: use addExtraClass())
20 * @param boolean $allowHTML Determine if the tag content needs to be escaped (Deprecated: use setAllowHTML())
21 * @param Form $form
22 */
23 function __construct($name, $title = null, $className = "", $allowHTML = false, $form = null) {
24 if($className) $this->extraClasses = array($className);
25 $this->allowHTML = $allowHTML;
26
27 parent::__construct($name, $title, null, $form);
28 }
29
30 /**
31 * Function that returns whether this field contains data.
32 * Always returns false.
33 */
34 function hasData() { return false; }
35
36 /**
37 * Returns the field's representation in the form.
38 * For dataless fields, this defaults to $Field.
39 */
40 function FieldHolder() {
41 return $this->Field();
42 }
43
44 /**
45 * Returns the field's representation in a field group.
46 * For dataless fields, this defaults to $Field.
47 */
48 function SmallFieldHolder() {
49 return $this->Field();
50 }
51
52 /**
53 * Returns a readonly version of this field
54 */
55 function performReadonlyTransformation() {
56 $clone = clone $this;
57 $clone->setReadonly(true);
58 return $clone;
59 }
60
61 /**
62 * @param bool $bool
63 */
64 function setAllowHTML($bool) {
65 $this->allowHTML = $bool;
66 }
67
68 /**
69 * @return bool
70 */
71 function getAllowHTML() {
72 return $this->allowHTML;
73 }
74 }
75 ?>