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
|
||||
|
||||
/**
|
||||
* Simple label tag. This can be used to add extra text in your forms.
|
||||
* Consider using a {@link ReadonlyField} if you need to display a label
|
||||
* AND a value.
|
||||
*
|
||||
* Simple label, to add extra text in your forms.
|
||||
*
|
||||
* Use a {@link ReadonlyField} if you need to display a label and value.
|
||||
*
|
||||
* @package forms
|
||||
* @subpackage fields-dataless
|
||||
*/
|
||||
class LabelField extends DatalessField {
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $title
|
||||
* @param Form $form
|
||||
* @param null|string $title
|
||||
*/
|
||||
public function __construct($name, $title) {
|
||||
// legacy handling for old parameters: $title, $heading, ...
|
||||
// instead of new handling: $name, $title, $heading, ...
|
||||
public function __construct($name, $title = null) {
|
||||
// legacy handling:
|
||||
// $title, $headingLevel...
|
||||
$args = func_get_args();
|
||||
|
||||
if(!isset($args[1])) {
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user