diff --git a/libraries/joomla/form/fields/textarea.php b/libraries/joomla/form/fields/textarea.php index 1d2079d513b9b..16d3a2091bef1 100644 --- a/libraries/joomla/form/fields/textarea.php +++ b/libraries/joomla/form/fields/textarea.php @@ -42,6 +42,14 @@ class JFormFieldTextarea extends JFormField */ protected $columns; + /** + * The maximum number of characters in textarea. + * + * @var mixed + * @since 3.4 + */ + protected $maxlength; + /** * Method to get certain otherwise inaccessible properties from the form field object. * @@ -57,6 +65,7 @@ public function __get($name) { case 'rows': case 'columns': + case 'maxlength': return $this->$name; } @@ -79,6 +88,7 @@ public function __set($name, $value) { case 'rows': case 'columns': + case 'maxlength': $this->$name = (int) $value; break; @@ -107,8 +117,9 @@ public function setup(SimpleXMLElement $element, $value, $group = null) if ($return) { - $this->rows = isset($this->element['rows']) ? (int) $this->element['rows'] : false; - $this->columns = isset($this->element['cols']) ? (int) $this->element['cols'] : false; + $this->rows = isset($this->element['rows']) ? (int) $this->element['rows'] : false; + $this->columns = isset($this->element['cols']) ? (int) $this->element['cols'] : false; + $this->maxlength = isset($this->element['maxlength']) ? (int) $this->element['maxlength'] : false; } return $return; @@ -139,6 +150,7 @@ protected function getInput() $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete; $autofocus = $this->autofocus ? ' autofocus' : ''; $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"'; + $maxlength = $this->maxlength ? ' maxlength="' . $this->maxlength . '"' : ''; // Initialize JavaScript field attributes. $onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : ''; @@ -149,7 +161,7 @@ protected function getInput() JHtml::_('script', 'system/html5fallback.js', false, true); return ''; } }