}
function getInputHTML( $value ) {
- $attribs = array(
+ $attribs = [
'id' => $this->mID,
'name' => $this->mName,
'size' => $this->getSize(),
'value' => $value,
'dir' => $this->mDir,
'spellcheck' => $this->getSpellCheck(),
- ) + $this->getTooltipAndAccessKey();
+ ] + $this->getTooltipAndAccessKey() + $this->getDataAttribs();
if ( $this->mClass !== '' ) {
$attribs['class'] = $this->mClass;
# @todo Enforce pattern, step, required, readonly on the server side as
# well
- $allowedParams = array(
+ $allowedParams = [
'type',
'min',
'max',
'autofocus',
'multiple',
'readonly'
- );
+ ];
$attribs += $this->getAttributes( $allowedParams );
$attribs = $this->getTooltipAndAccessKey();
if ( $this->mClass !== '' ) {
- $attribs['classes'] = array( $this->mClass );
+ $attribs['classes'] = [ $this->mClass ];
}
# @todo Enforce pattern, step, required, readonly on the server side as
# well
- $allowedParams = array(
+ $allowedParams = [
'autofocus',
'autosize',
'disabled',
'required',
'tabindex',
'type',
- );
+ ];
- $attribs += $this->getAttributes( $allowedParams, array(
+ $attribs += $this->getAttributes( $allowedParams, [
'maxlength' => 'maxLength',
'readonly' => 'readOnly',
'tabindex' => 'tabIndex',
- ) );
-
- if ( isset( $attribs['readOnly'] ) ) {
- // This needs to be set to a boolean value
- $attribs['readOnly'] = true;
- }
+ ] );
$type = $this->getType( $attribs );
- return new OOUI\TextInputWidget( array(
+ return $this->getInputWidget( [
'id' => $this->mID,
'name' => $this->mName,
'value' => $value,
'type' => $type,
- ) + $attribs );
+ ] + $attribs );
+ }
+
+ protected function getInputWidget( $params ) {
+ return new OOUI\TextInputWidget( $params );
+ }
+
+ /**
+ * Returns an array of data-* attributes to add to the field.
+ *
+ * @return array
+ */
+ protected function getDataAttribs() {
+ return [];
}
}