From: Fomafix Date: Wed, 27 Jun 2018 20:13:01 +0000 (+0200) Subject: Allow overloading of getLabel() with return ' ' X-Git-Tag: 1.34.0-rc.0~4934 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=f02eed24ac2e152b40cda19d5fbb3b1346b2e7d8;p=lhc%2Fweb%2Fwiklou.git Allow overloading of getLabel() with return ' ' This is a follow-up to 125cbd8c017b872c78f047c08f494a458883db23. Bug: T198338 Change-Id: I21626326dde368d70fcc33052e43ff90db5ea9c0 --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index e4f174323c..b5fb87f9e4 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -1662,7 +1662,7 @@ class HTMLForm extends ContextSource { $html[] = $retval; $labelValue = trim( $value->getLabel() ); - if ( $labelValue !== "\u{00A0}" && $labelValue !== '' ) { + if ( $labelValue !== "\u{00A0}" && $labelValue !== ' ' && $labelValue !== '' ) { $hasLabel = true; } diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 31c72607fc..83fe65a27d 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -630,7 +630,7 @@ abstract class HTMLFormField { // the element could specify, that the label doesn't need to be added $label = $this->getLabel(); - if ( $label && $label !== "\u{00A0}" ) { + if ( $label && $label !== "\u{00A0}" && $label !== ' ' ) { $config['label'] = new OOUI\HtmlSnippet( $label ); } @@ -926,13 +926,7 @@ abstract class HTMLFormField { * @return string HTML */ public function getLabel() { - if ( is_null( $this->mLabel ) ) { - return ''; - } - if ( $this->mLabel === ' ' ) { - return "\u{00A0}"; - } - return $this->mLabel; + return $this->mLabel ?? ''; } public function getLabelHtml( $cellAttributes = [] ) { @@ -946,7 +940,7 @@ abstract class HTMLFormField { $labelValue = trim( $this->getLabel() ); $hasLabel = false; - if ( $labelValue !== "\u{00A0}" && $labelValue !== '' ) { + if ( $labelValue !== "\u{00A0}" && $labelValue !== ' ' && $labelValue !== '' ) { $hasLabel = true; } diff --git a/includes/htmlform/fields/HTMLFormFieldCloner.php b/includes/htmlform/fields/HTMLFormFieldCloner.php index dec162fe50..aae3af262f 100644 --- a/includes/htmlform/fields/HTMLFormFieldCloner.php +++ b/includes/htmlform/fields/HTMLFormFieldCloner.php @@ -296,7 +296,7 @@ class HTMLFormFieldCloner extends HTMLFormField { $html .= $field->$getFieldHtmlMethod( $v ); $labelValue = trim( $field->getLabel() ); - if ( $labelValue != "\u{00A0}" && $labelValue !== '' ) { + if ( $labelValue !== "\u{00A0}" && $labelValue !== ' ' && $labelValue !== '' ) { $hasLabel = true; } }