1 <?php
2 /**
3 * This field lets you put an arbitrary piece of HTML into your forms.
4 *
5 * @package forms
6 * @subpackage fields-dataless
7 */
8 class LiteralField extends DatalessField {
9
10 /**
11 * @var string $content
12 */
13 protected $content;
14
15 function __construct($name, $content) {
16 $this->content = $content;
17
18 parent::__construct($name);
19 }
20
21 function FieldHolder() {
22 return is_object($this->content) ? $this->content->forTemplate() : $this->content;
23 }
24
25 function Field() {
26 return $this->FieldHolder();
27 }
28
29 /**
30 * Sets the content of this field to a new value
31 * @param string $content
32 */
33 function setContent($content) {
34 $this->content = $content;
35 }
36
37 /**
38 * @return string
39 */
40 function getContent() {
41 return $this->content;
42 }
43
44 /**
45 * Synonym of {@link setContent()} so that LiteralField is more compatible with other field types.
46 */
47 function setValue($value) {
48 return $this->setContent($value);
49 }
50
51 function performReadonlyTransformation() {
52 $clone = clone $this;
53 $clone->setReadonly(true);
54 return $clone;
55 }
56 }
57
58 ?>