mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Enable max length for textarea field
This commit is contained in:
parent
825ed22214
commit
442f2bb762
@ -79,6 +79,13 @@ class TextField extends FormField
|
||||
);
|
||||
}
|
||||
|
||||
public function getSchemaDataDefaults()
|
||||
{
|
||||
$data = parent::getSchemaDataDefaults();
|
||||
$data['data']['maxlength'] = $this->getMaxLength();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -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(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
"disabled": false,
|
||||
"autoFocus": false,
|
||||
"customValidationMessage": "",
|
||||
"maxLength": 40,
|
||||
"validation": {
|
||||
"required": true,
|
||||
"max": {
|
||||
|
Loading…
Reference in New Issue
Block a user