Merge "HTMLForm: Do not render hidden elements as elements"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 19 Nov 2015 16:28:05 +0000 (16:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 19 Nov 2015 16:28:05 +0000 (16:28 +0000)
1  2 
includes/htmlform/HTMLForm.php

@@@ -1359,18 -1359,6 +1359,18 @@@ class HTMLForm extends ContextSource 
                return $this->mMethod;
        }
  
 +      /**
 +       * Wraps the given $section into an user-visible fieldset.
 +       *
 +       * @param string $legend Legend text for the fieldset
 +       * @param string $section The section content in plain Html
 +       * @param array $attributes Additional attributes for the fieldset
 +       * @return string The fieldset's Html
 +       */
 +      protected function wrapFieldSetSection( $legend, $section, $attributes ) {
 +              return Xml::fieldset( $legend, $section, $attributes ) . "\n";
 +      }
 +
        /**
         * @todo Document
         *
                                $v = empty( $value->mParams['nodata'] )
                                        ? $this->mFieldData[$key]
                                        : $value->getDefault();
-                               $html[] = $value->$getFieldHtmlMethod( $v );
  
-                               $labelValue = trim( $value->getLabel() );
-                               if ( $labelValue != '&#160;' && $labelValue !== '' ) {
-                                       $hasLabel = true;
-                               }
+                               $retval = $value->$getFieldHtmlMethod( $v );
+                               // check, if the form field should be added to
+                               // the output.
+                               if ( $value->hasVisibleOutput() ) {
+                                       $html[] = $retval;
+                                       $labelValue = trim( $value->getLabel() );
+                                       if ( $labelValue != '&#160;' && $labelValue !== '' ) {
+                                               $hasLabel = true;
+                                       }
  
-                               if ( get_class( $value ) !== 'HTMLHiddenField' &&
-                                       get_class( $value ) !== 'HTMLApiField'
-                               ) {
                                        $hasUserVisibleFields = true;
                                }
                        } elseif ( is_array( $value ) ) {
                                        if ( $fieldsetIDPrefix ) {
                                                $attributes['id'] = Sanitizer::escapeId( "$fieldsetIDPrefix$key" );
                                        }
 -                                      $subsectionHtml .= Xml::fieldset( $legend, $section, $attributes ) . "\n";
 +                                      $subsectionHtml .= $this->wrapFieldSetSection( $legend, $section, $attributes );
                                } else {
                                        // Just return the inputs, nothing fancy.
                                        $subsectionHtml .= $section;