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
|
|
|
*/
|
|
|
|
class LabelField extends DatalessField {
|
|
|
|
/**
|
2008-10-16 15:26:25 +02:00
|
|
|
* @param string $name
|
2015-04-27 23:12:32 +02:00
|
|
|
* @param null|string $title
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2015-04-27 23:12:32 +02:00
|
|
|
public function __construct($name, $title = null) {
|
|
|
|
// legacy handling:
|
|
|
|
// $title, $headingLevel...
|
2008-10-16 15:26:25 +02:00
|
|
|
$args = func_get_args();
|
2015-04-27 23:12:32 +02:00
|
|
|
|
2008-10-16 15:26:25 +02:00
|
|
|
if(!isset($args[1])) {
|
|
|
|
$title = (isset($args[0])) ? $args[0] : null;
|
2015-04-27 23:12:32 +02:00
|
|
|
|
|
|
|
if(isset($args[0])) {
|
|
|
|
$title = $args[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prefix name to avoid collisions.
|
2016-08-19 00:51:35 +02:00
|
|
|
/** @skipUpgrade */
|
2015-04-27 23:12:32 +02:00
|
|
|
$name = 'LabelField' . $title;
|
|
|
|
}
|
|
|
|
|
2012-01-02 17:09:30 +01:00
|
|
|
parent::__construct($name, $title);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|