Clean up LabelField

This commit is contained in:
Christopher Pitt 2015-04-28 09:12:32 +12:00
parent 72ee96cd65
commit e1df8ec2fc
1 changed files with 19 additions and 15 deletions

View File

@ -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);
}
}