mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 17:05:50 +02:00
7ecbf49ac9
git-svn-id: http://svn.silverstripe.com/projects/ss2doc/branches/v2@117896 467b73ca-7a2a-4603-9d3b-597d59a354a9
67 lines
1.2 KiB
PHP
Executable File
67 lines
1.2 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* This field lets you put an arbitrary piece of HTML into your forms.
|
|
*
|
|
* <b>Usage</b>
|
|
*
|
|
* <code>
|
|
* new LiteralField (
|
|
* $name = "literalfield",
|
|
* $content = '<b>some bold text</b> and <a href="http://silverstripe.com">a link</a>'
|
|
* )
|
|
* </code>
|
|
*
|
|
* @package forms
|
|
* @subpackage fields-dataless
|
|
*/
|
|
class LiteralField extends DatalessField {
|
|
|
|
/**
|
|
* @var string $content
|
|
*/
|
|
protected $content;
|
|
|
|
function __construct($name, $content) {
|
|
$this->content = $content;
|
|
|
|
parent::__construct($name);
|
|
}
|
|
|
|
function FieldHolder() {
|
|
return is_object($this->content) ? $this->content->forTemplate() : $this->content;
|
|
}
|
|
|
|
function Field() {
|
|
return $this->FieldHolder();
|
|
}
|
|
|
|
/**
|
|
* Sets the content of this field to a new value
|
|
* @param string $content
|
|
*/
|
|
function setContent($content) {
|
|
$this->content = $content;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
function getContent() {
|
|
return $this->content;
|
|
}
|
|
|
|
/**
|
|
* Synonym of {@link setContent()} so that LiteralField is more compatible with other field types.
|
|
*/
|
|
function setValue($value) {
|
|
return $this->setContent($value);
|
|
}
|
|
|
|
function performReadonlyTransformation() {
|
|
$clone = clone $this;
|
|
$clone->setReadonly(true);
|
|
return $clone;
|
|
}
|
|
}
|
|
|
|
?>
|