Skip to content

Commit

Permalink
Missing form field attribute "maxlength".
Browse files Browse the repository at this point in the history
  • Loading branch information
Todor Iliev committed Apr 26, 2014
1 parent f93b85f commit 5c73a01
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libraries/joomla/form/fields/textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class JFormFieldTextarea extends JFormField
*/
protected $type = 'Textarea';

/**
* The allowable maxlength of the field.
*
* @var integer
* @since 3.2
*/
protected $maxLength;

/**
* The number of rows in textarea.
*
Expand Down Expand Up @@ -57,6 +65,7 @@ public function __get($name)
{
switch ($name)
{
case 'maxLength':
case 'rows':
case 'columns':
return $this->$name;
Expand All @@ -79,6 +88,9 @@ public function __set($name, $value)
{
switch ($name)
{
case 'maxLength':
$this->maxLength = (int) $value;
break;
case 'rows':
case 'columns':
$this->$name = (int) $value;
Expand Down Expand Up @@ -111,6 +123,8 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$this->rows = isset($this->element['rows']) ? (int) $this->element['rows'] : false;
$this->columns = isset($this->element['cols']) ? (int) $this->element['cols'] : false;

$this->maxLength = (int) $this->element['maxlength'];
}

return $return;
Expand Down Expand Up @@ -141,6 +155,7 @@ protected function getInput()
$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
$autofocus = $this->autofocus ? ' autofocus' : '';
$spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
$maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';

// Initialize JavaScript field attributes.
$onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
Expand All @@ -151,7 +166,7 @@ protected function getInput()
JHtml::_('script', 'system/html5fallback.js', false, true);

return '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class
. $hint . $disabled . $readonly . $onchange . $onclick . $required . $autocomplete . $autofocus . $spellcheck . ' >'
. $hint . $disabled . $readonly . $onchange . $onclick . $maxLength . $required . $autocomplete . $autofocus . $spellcheck . ' >'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '</textarea>';
}
}

0 comments on commit 5c73a01

Please sign in to comment.