From 62d54bed13ddee3355fd64946013bd3173465c16 Mon Sep 17 00:00:00 2001 From: "Daniel A. R. Werner" Date: Tue, 19 May 2015 00:35:15 +0200 Subject: [PATCH] "spellcheck" attribute for HTMLForm "text" and "textarea" "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 --- includes/htmlform/HTMLTextAreaField.php | 10 ++++++++++ includes/htmlform/HTMLTextField.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/includes/htmlform/HTMLTextAreaField.php b/includes/htmlform/HTMLTextAreaField.php index 21173d2a63..ba9707dc34 100644 --- a/includes/htmlform/HTMLTextAreaField.php +++ b/includes/htmlform/HTMLTextAreaField.php @@ -12,11 +12,21 @@ class HTMLTextAreaField extends HTMLFormField { 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 !== '' ) { diff --git a/includes/htmlform/HTMLTextField.php b/includes/htmlform/HTMLTextField.php index a67e52e636..76278db99e 100644 --- a/includes/htmlform/HTMLTextField.php +++ b/includes/htmlform/HTMLTextField.php @@ -5,6 +5,15 @@ class HTMLTextField extends HTMLFormField { return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45; } + 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, @@ -12,6 +21,7 @@ class HTMLTextField extends HTMLFormField { 'size' => $this->getSize(), 'value' => $value, 'dir' => $this->mDir, + 'spellcheck' => $this->getSpellCheck(), ) + $this->getTooltipAndAccessKey(); if ( $this->mClass !== '' ) { -- 2.20.1