silverstripe-framework/forms/LiteralField.php
Ingo Schommer e95c5657ff API CHANGE Changed constructor parameters for LabelField and Header: First parameter is now $name, not $title. Necessary change to consistently support labelled fields which can be identified and modified within a FieldSet, and in the DOM structure. Both HeaderField and LabelField still acceppt old notation through checking the parameter signature with func_get_args().
API CHANGE Moved setAllowHTML() to DataLessField
ENHANCEMENT Using createTag() to create HeaderField and LabelField, which adds support for HTML id attributes and extra css classes through addExtraClass()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64421 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-10-16 13:26:25 +00:00

50 lines
856 B
PHP
Executable File

<?php
/**
* This field lets you put an arbitrary piece of HTML into your forms.
*
* @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;
}
function performReadonlyTransformation() {
$this->setReadonly(true);
return $this;
}
}
?>