silverstripe-framework/Forms/LabelField.php

35 lines
683 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.
*/
class LabelField extends DatalessField {
/**
* @param string $name
2015-04-27 23:12:32 +02:00
* @param null|string $title
*/
2015-04-27 23:12:32 +02:00
public function __construct($name, $title = null) {
// legacy handling:
// $title, $headingLevel...
$args = func_get_args();
2015-04-27 23:12:32 +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.
/** @skipUpgrade */
2015-04-27 23:12:32 +02:00
$name = 'LabelField' . $title;
}
parent::__construct($name, $title);
}
}