2007-07-19 10:40:28 +00:00
|
|
|
<?php
|
2015-04-28 09:12:32 +12:00
|
|
|
|
2016-08-19 10:51:35 +12:00
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2007-07-19 10:40:28 +00:00
|
|
|
/**
|
2015-04-28 09:12:32 +12:00
|
|
|
* Simple label, to add extra text in your forms.
|
|
|
|
*
|
|
|
|
* Use a {@link ReadonlyField} if you need to display a label and value.
|
2007-07-19 10:40:28 +00:00
|
|
|
*/
|
2016-11-29 12:31:16 +13:00
|
|
|
class LabelField extends DatalessField
|
|
|
|
{
|
2017-03-20 14:02:43 +13:00
|
|
|
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL;
|
2017-07-03 12:21:27 +12:00
|
|
|
|
|
|
|
/** @skipUpgrade */
|
2017-03-20 14:02:43 +13:00
|
|
|
protected $schemaComponent = 'LabelField';
|
2017-07-03 12:21:27 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
* @param null|string $title
|
|
|
|
*/
|
|
|
|
public function __construct($name, $title = null)
|
|
|
|
{
|
|
|
|
// legacy handling:
|
|
|
|
// $title, $headingLevel...
|
|
|
|
$args = func_get_args();
|
2015-04-28 09:12:32 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
if (!isset($args[1])) {
|
|
|
|
$title = (isset($args[0])) ? $args[0] : null;
|
2015-04-28 09:12:32 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
if (isset($args[0])) {
|
|
|
|
$title = $args[0];
|
|
|
|
}
|
2015-04-28 09:12:32 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
// Prefix name to avoid collisions.
|
|
|
|
/** @skipUpgrade */
|
|
|
|
$name = 'LabelField' . $title;
|
|
|
|
}
|
2015-04-28 09:12:32 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
parent::__construct($name, $title);
|
|
|
|
}
|
2012-03-24 16:04:52 +13:00
|
|
|
}
|