Enable max length for textarea field

This commit is contained in:
Saophalkun Ponlu 2017-12-04 16:40:40 +13:00
parent 825ed22214
commit 442f2bb762
3 changed files with 38 additions and 6 deletions

View File

@ -79,6 +79,13 @@ class TextField extends FormField
);
}
public function getSchemaDataDefaults()
{
$data = parent::getSchemaDataDefaults();
$data['data']['maxlength'] = $this->getMaxLength();
return $data;
}
/**
* @return string
*/

View File

@ -45,16 +45,20 @@ class TextareaField extends FormField
*/
protected $cols = 20;
/**
* @var int
*/
protected $maxLength;
/**
* Set textarea specific schema data
*/
public function getSchemaDataDefaults()
{
$data = parent::getSchemaDataDefaults();
$data['data']['rows'] = $this->getRows();
$data['data']['columns'] = $this->getColumns();
$data['data']['maxlength'] = $this->getMaxLength();
return $data;
}
@ -106,6 +110,25 @@ class TextareaField extends FormField
return $this->cols;
}
/**
* @param int $maxLength
* @return $this
*/
public function setMaxLength($maxLength)
{
$this->maxLength = $maxLength;
return $this;
}
/**
* @return null|int
*/
public function getMaxLength()
{
return $this->maxLength;
}
/**
* {@inheritdoc}
*/
@ -117,7 +140,8 @@ class TextareaField extends FormField
'rows' => $this->getRows(),
'cols' => $this->getColumns(),
'value' => null,
'type' => null
'type' => null,
'maxlength' => $this->getMaxLength(),
)
);
}

View File

@ -30,6 +30,7 @@
"disabled": false,
"autoFocus": false,
"customValidationMessage": "",
"maxLength": 40,
"validation": {
"required": true,
"max": {