Merge "Merge namespace aliases like we merge namespace names"
[lhc/web/wiklou.git] / includes / htmlform / HTMLForm.php
index 2779d5a..b0d90af 100644 (file)
@@ -128,6 +128,7 @@ class HTMLForm extends ContextSource {
                'textwithbutton' => 'HTMLTextFieldWithButton',
                'textarea' => 'HTMLTextAreaField',
                'select' => 'HTMLSelectField',
+               'combobox' => 'HTMLComboboxField',
                'radio' => 'HTMLRadioField',
                'multiselect' => 'HTMLMultiSelectField',
                'limitselect' => 'HTMLSelectLimitField',
@@ -959,7 +960,11 @@ class HTMLForm extends ContextSource {
                        $html = Xml::fieldset( $legend, $html );
                }
 
-               return Html::rawElement( 'form', $this->getFormAttributes() + array( 'class' => 'visualClear' ), $html );
+               return Html::rawElement(
+                       'form',
+                       $this->getFormAttributes() + array( 'class' => 'visualClear' ),
+                       $html
+               );
        }
 
        /**
@@ -1355,6 +1360,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
         *
@@ -1386,16 +1403,19 @@ class HTMLForm extends ContextSource {
                                $v = empty( $value->mParams['nodata'] )
                                        ? $this->mFieldData[$key]
                                        : $value->getDefault();
-                               $html[] = $value->$getFieldHtmlMethod( $v );
 
-                               $labelValue = trim( $value->getLabel() );
-                               if ( $labelValue != ' ' && $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 != ' ' && $labelValue !== '' ) {
+                                               $hasLabel = true;
+                                       }
 
-                               if ( get_class( $value ) !== 'HTMLHiddenField' &&
-                                       get_class( $value ) !== 'HTMLApiField'
-                               ) {
                                        $hasUserVisibleFields = true;
                                }
                        } elseif ( is_array( $value ) ) {
@@ -1421,7 +1441,7 @@ class HTMLForm extends ContextSource {
                                        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;