1 <?php
2 3 4 5 6 7
8 class LiteralField extends DatalessField {
9
10 11 12
13 protected $content;
14
15 function __construct($name, $content) {
16 $this->content = $content;
17
18 parent::__construct($name);
19 }
20
21 function Field() {
22 $attributes = array(
23 'type' => 'literal',
24 );
25 return $this->createTag('span', $attributes, is_object($this->content) ? $this->content->forTemplate() : $this->content);
26 }
27
28 29 30 31
32 function setContent($content) {
33 $this->content = $content;
34 }
35
36 37 38
39 function getContent() {
40 return $this->content;
41 }
42
43 44 45
46 function setValue($value) {
47 return $this->setContent($value);
48 }
49
50 function performReadonlyTransformation() {
51 $clone = clone $this;
52 $clone->setReadonly(true);
53 return $clone;
54 }
55 }
56
57 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-