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