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
|
||||
*/
|
||||
|
@ -28,9 +28,9 @@ class TextareaField extends FormField
|
||||
'Value' => 'Text',
|
||||
'ValueEntities' => 'HTMLFragment(array(\'shortcodes\' => false))',
|
||||
);
|
||||
|
||||
|
||||
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TEXT;
|
||||
|
||||
|
||||
/**
|
||||
* Visible number of text lines.
|
||||
*
|
||||
@ -45,19 +45,23 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the number of rows in the textarea
|
||||
*
|
||||
@ -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