silverstripe-framework/src/Forms/LabelField.php

42 lines
954 B
PHP
Raw Normal View History

<?php
2015-04-27 23:12:32 +02:00
namespace SilverStripe\Forms;
/**
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.
*/
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;
/** @skipUpgrade */
2017-03-20 02:02:43 +01:00
protected $schemaComponent = 'LabelField';
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);
}
}