Upgrade premature implicit transaction commits to exceptions
[lhc/web/wiklou.git] / includes / htmlform / HTMLCheckMatrix.php
index 6a4bec8..b324fb6 100644 (file)
@@ -85,13 +85,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                $rows = $this->mParams['rows'];
                $columns = $this->mParams['columns'];
 
-               $mappings = [];
-
-               if ( $this->mParent instanceof OOUIHTMLForm ) {
-                       $mappings['tabindex'] = 'tabIndex';
-               }
-
-               $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ], $mappings );
+               $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
 
                // Build the column headers
                $headerContents = Html::rawElement( 'td', [], ' ' );
@@ -156,8 +150,9 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                        return new OOUI\CheckboxInputWidget( [
                                'name' => "{$this->mName}[]",
                                'selected' => $checked,
-                               'value' => $attribs['value'],
-                       ] + $attribs );
+                       ] + OOUI\Element::configFromHtmlAttributes(
+                               $attribs
+                       ) );
                } else {
                        $checkbox = Xml::check( "{$this->mName}[]", $checked, $attribs );
                        if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
@@ -230,22 +225,13 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
         * @return array
         */
        function loadDataFromRequest( $request ) {
-               if ( $this->mParent->getMethod() == 'post' ) {
-                       if ( $request->wasPosted() ) {
-                               // Checkboxes are not added to the request arrays if they're not checked,
-                               // so it's perfectly possible for there not to be an entry at all
-                               return $request->getArray( $this->mName, [] );
-                       } else {
-                               // That's ok, the user has not yet submitted the form, so show the defaults
-                               return $this->getDefault();
-                       }
-               } else {
-                       // This is the impossible case: if we look at $_GET and see no data for our
-                       // field, is it because the user has not yet submitted the form, or that they
-                       // have submitted it with all the options unchecked. We will have to assume the
-                       // latter, which basically means that you can't specify 'positive' defaults
-                       // for GET forms.
+               if ( $this->isSubmitAttempt( $request ) ) {
+                       // Checkboxes are just not added to the request arrays if they're not checked,
+                       // so it's perfectly possible for there not to be an entry at all
                        return $request->getArray( $this->mName, [] );
+               } else {
+                       // That's ok, the user has not yet submitted the form, so show the defaults
+                       return $this->getDefault();
                }
        }