2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2015-04-27 23:12:32 +02: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 12:40:28 +02:00
|
|
|
*/
|
2016-11-29 00:31:16 +01:00
|
|
|
class LabelField extends DatalessField
|
|
|
|
{
|
2017-03-20 02:02:43 +01:00
|
|
|
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL;
|
2017-07-03 02:21:27 +02:00
|
|
|
|
|
|
|
/** @skipUpgrade */
|
2017-03-20 02:02:43 +01:00
|
|
|
protected $schemaComponent = 'LabelField';
|
2017-07-03 02:21:27 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
* @param null|string $title
|
|
|
|
*/
|
|
|
|
public function __construct($name, $title = null)
|
|
|
|
{
|
|
|
|
// legacy handling:
|
|
|
|
// $title, $headingLevel...
|
|
|
|
$args = func_get_args();
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
if (!isset($args[1])) {
|
|
|
|
$title = (isset($args[0])) ? $args[0] : null;
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
if (isset($args[0])) {
|
|
|
|
$title = $args[0];
|
|
|
|
}
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
// Prefix name to avoid collisions.
|
|
|
|
/** @skipUpgrade */
|
|
|
|
$name = 'LabelField' . $title;
|
|
|
|
}
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
parent::__construct($name, $title);
|
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|