"spellcheck" attribute requires literal "true" or "false" values and can not just be implemented by adding it to the list of HTMLFormField::getAttributes's $boolAttribs. Change-Id: I5882e71af2ca64d367a1824634f61e16097e341d
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
class HTMLTextAreaField extends HTMLFormField {
|
|
const DEFAULT_COLS = 80;
|
|
const DEFAULT_ROWS = 25;
|
|
|
|
function getCols() {
|
|
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
|
|
}
|
|
|
|
function getRows() {
|
|
return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
|
|
}
|
|
|
|
function getSpellCheck() {
|
|
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
|
|
if( is_bool( $val ) ) {
|
|
// "spellcheck" attribute literally requires "true" or "false" to work.
|
|
return $val === true ? 'true' : 'false';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function getInputHTML( $value ) {
|
|
$attribs = array(
|
|
'id' => $this->mID,
|
|
'cols' => $this->getCols(),
|
|
'rows' => $this->getRows(),
|
|
'spellcheck' => $this->getSpellCheck(),
|
|
) + $this->getTooltipAndAccessKey();
|
|
|
|
if ( $this->mClass !== '' ) {
|
|
$attribs['class'] = $this->mClass;
|
|
}
|
|
|
|
$allowedParams = array(
|
|
'placeholder',
|
|
'tabindex',
|
|
'disabled',
|
|
'readonly',
|
|
'required',
|
|
'autofocus'
|
|
);
|
|
|
|
$attribs += $this->getAttributes( $allowedParams );
|
|
return Html::textarea( $this->mName, $value, $attribs );
|
|
}
|
|
}
|