$textAttribs['class'][] = $this->mClass;
}
+ if ( isset( $this->mParams['maxlength-unit'] ) ) {
+ $textAttribs['data-mw-maxlength-unit'] = $this->mParams['maxlength-unit'];
+ }
+
$allowedParams = [
'required',
'autofocus',
'disabled',
'tabindex',
'maxlength', // gets dynamic with javascript, see mediawiki.htmlform.js
+ 'maxlength-unit', // 'bytes' or 'codepoints', see mediawiki.htmlform.js
];
$textAttribs += $this->getAttributes( $allowedParams );
# TextInput
$textAttribs = [
'name' => $this->mName . '-other',
- 'size' => $this->getSize(),
- 'class' => [ 'mw-htmlform-select-and-other-field' ],
- 'data-id-select' => $this->mID . '-select',
'value' => $value[2],
];
'textinput' => $textAttribs,
'dropdowninput' => $dropdownInputAttribs,
'or' => false,
+ 'classes' => [ 'mw-htmlform-select-and-other-field' ],
+ 'data' => [
+ 'maxlengthUnit' => $this->mParams['maxlength-unit'] ?? 'bytes'
+ ],
] );
}
}
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
+ return $this->mParams['size'] ?? 45;
}
public function validate( $value, $alldata ) {