From: Daniel A. R. Werner Date: Mon, 18 May 2015 22:35:15 +0000 (+0200) Subject: "spellcheck" attribute for HTMLForm "text" and "textarea" X-Git-Tag: 1.31.0-rc.0~10982^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=62d54bed13ddee3355fd64946013bd3173465c16;p=lhc%2Fweb%2Fwiklou.git "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 --- 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 !== '' ) {