2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2016-08-19 00:51:35 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2016-07-12 08:51:08 +02:00
|
|
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
|
|
|
* Abstract class for all fields without data.
|
|
|
|
* Labels, headings and the like should extend from this.
|
|
|
|
*/
|
2016-11-29 00:31:16 +01:00
|
|
|
class DatalessField extends FormField
|
|
|
|
{
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* @var bool $allowHTML
|
|
|
|
*/
|
|
|
|
protected $allowHTML;
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* function that returns whether this field contains data.
|
|
|
|
* Always returns false.
|
|
|
|
*/
|
|
|
|
public function hasData()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-22 13:10:57 +01:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
public function getAttributes()
|
|
|
|
{
|
|
|
|
return array_merge(
|
|
|
|
parent::getAttributes(),
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* Returns the field's representation in the form.
|
|
|
|
* For dataless fields, this defaults to $Field.
|
|
|
|
*
|
|
|
|
* @param array $properties
|
|
|
|
* @return DBHTMLText
|
|
|
|
*/
|
|
|
|
public function FieldHolder($properties = array())
|
|
|
|
{
|
|
|
|
return $this->Field($properties);
|
|
|
|
}
|
2007-07-19 12:40:28 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* Returns the field's representation in a field group.
|
|
|
|
* For dataless fields, this defaults to $Field.
|
|
|
|
*
|
|
|
|
* @param array $properties
|
|
|
|
* @return DBHTMLText
|
|
|
|
*/
|
|
|
|
public function SmallFieldHolder($properties = array())
|
|
|
|
{
|
|
|
|
return $this->Field($properties);
|
|
|
|
}
|
2007-07-19 12:40:28 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* Returns a readonly version of this field
|
|
|
|
*/
|
|
|
|
public function performReadonlyTransformation()
|
|
|
|
{
|
|
|
|
$clone = clone $this;
|
|
|
|
$clone->setReadonly(true);
|
|
|
|
return $clone;
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* @param bool $bool
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setAllowHTML($bool)
|
|
|
|
{
|
|
|
|
$this->allowHTML = $bool;
|
|
|
|
return $this;
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getAllowHTML()
|
|
|
|
{
|
|
|
|
return $this->allowHTML;
|
|
|
|
}
|
2011-12-22 13:10:57 +01:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
public function Type()
|
|
|
|
{
|
|
|
|
return 'readonly';
|
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|