"spellcheck" attribute for HTMLForm "text" and "textarea"
authorDaniel A. R. Werner <daniel.a.r.werner@gmail.com>
Mon, 18 May 2015 22:35:15 +0000 (00:35 +0200)
committerDaniel A. R. Werner <daniel.a.r.werner@gmail.com>
Sat, 13 Jun 2015 13:23:48 +0000 (15:23 +0200)
"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
includes/htmlform/HTMLTextField.php

index 21173d2..ba9707d 100644 (file)
@@ -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 !== '' ) {
index a67e52e..76278db 100644 (file)
@@ -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 !== '' ) {