(bug 40889) Follow-up 6f1d4db3: Fix the upload form when radio buttons are shown.
authorVitaliy Filippov <vitalif@yourcmc.ru>
Tue, 8 Oct 2013 11:15:03 +0000 (15:15 +0400)
committerIAlex <codereview@emsenhuber.ch>
Sat, 14 Dec 2013 14:34:47 +0000 (14:34 +0000)
The previous change had broken the upload form if URL uploads or
some other possible upload source types are enabled - i.e. in
the case when there are radio buttons. The "incorrect" label ID
was used by radiobutton.

Change-Id: I7c15fd4250b6a2d26af2cc0373da5ac6c884d690

includes/specials/SpecialUpload.php

index 5e1591d..7c05001 100644 (file)
@@ -1107,10 +1107,8 @@ class UploadSourceField extends HTMLTextField {
         * @return string
         */
        function getLabelHtml( $cellAttributes = array() ) {
-               $id = $this->mParams['id'];
-               $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
-
                if ( !empty( $this->mParams['radio'] ) ) {
+                       $id = "wpSourceType{$this->mParams['upload-type']}";
                        $attribs = array(
                                'name' => 'wpSourceType',
                                'type' => 'radio',
@@ -1120,9 +1118,12 @@ class UploadSourceField extends HTMLTextField {
                        if ( !empty( $this->mParams['checked'] ) ) {
                                $attribs['checked'] = 'checked';
                        }
+                       $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
                        $label .= Html::element( 'input', $attribs );
+               } else {
+                       $id = $this->mParams['id'];
+                       $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
                }
-
                return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes, $label );
        }