mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Clean up LabelField
This commit is contained in:
parent
72ee96cd65
commit
e1df8ec2fc
@ -1,30 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple label tag. This can be used to add extra text in your forms.
|
* Simple label, to add extra text in your forms.
|
||||||
* Consider using a {@link ReadonlyField} if you need to display a label
|
*
|
||||||
* AND a value.
|
* Use a {@link ReadonlyField} if you need to display a label and value.
|
||||||
*
|
*
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage fields-dataless
|
* @subpackage fields-dataless
|
||||||
*/
|
*/
|
||||||
class LabelField extends DatalessField {
|
class LabelField extends DatalessField {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $title
|
* @param null|string $title
|
||||||
* @param Form $form
|
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $title) {
|
public function __construct($name, $title = null) {
|
||||||
// legacy handling for old parameters: $title, $heading, ...
|
// legacy handling:
|
||||||
// instead of new handling: $name, $title, $heading, ...
|
// $title, $headingLevel...
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
||||||
if(!isset($args[1])) {
|
if(!isset($args[1])) {
|
||||||
$title = (isset($args[0])) ? $args[0] : null;
|
$title = (isset($args[0])) ? $args[0] : null;
|
||||||
$name = $title;
|
|
||||||
$form = (isset($args[3])) ? $args[3] : null;
|
if(isset($args[0])) {
|
||||||
}
|
$title = $args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefix name to avoid collisions.
|
||||||
|
$name = 'LabelField' . $title;
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct($name, $title);
|
parent::__construct($name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user