$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', [], ' ' );
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' ) ) {
* @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();
}
}