Allow overloading of getLabel() with return ' '
authorFomafix <fomafix@googlemail.com>
Wed, 27 Jun 2018 20:13:01 +0000 (22:13 +0200)
committerFomafix <fomafix@googlemail.com>
Thu, 28 Jun 2018 09:25:39 +0000 (11:25 +0200)
This is a follow-up to 125cbd8c017b872c78f047c08f494a458883db23.

Bug: T198338
Change-Id: I21626326dde368d70fcc33052e43ff90db5ea9c0

includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php
includes/htmlform/fields/HTMLFormFieldCloner.php

index e4f1743..b5fb87f 100644 (file)
@@ -1662,7 +1662,7 @@ class HTMLForm extends ContextSource {
                                        $html[] = $retval;
 
                                        $labelValue = trim( $value->getLabel() );
-                                       if ( $labelValue !== "\u{00A0}" && $labelValue !== '' ) {
+                                       if ( $labelValue !== "\u{00A0}" && $labelValue !== '&#160;' && $labelValue !== '' ) {
                                                $hasLabel = true;
                                        }
 
index 31c7260..83fe65a 100644 (file)
@@ -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 !== '&#160;' ) {
                        $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 === '&#160;' ) {
-                       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 !== '&#160;' && $labelValue !== '' ) {
                        $hasLabel = true;
                }
 
index dec162f..aae3af2 100644 (file)
@@ -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 !== '&#160;' && $labelValue !== '' ) {
                                        $hasLabel = true;
                                }
                        }