mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Clean up TextareaField
This commit is contained in:
parent
72ee96cd65
commit
53cf2929d4
@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TextareaField creates a multi-line text field,
|
||||
* allowing more data to be entered than a standard
|
||||
* text field. It creates the <textarea> tag in the
|
||||
* form HTML.
|
||||
*
|
||||
* <b>Usage</b>
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* new TextareaField(
|
||||
* $name = "description",
|
||||
@ -14,22 +13,54 @@
|
||||
* $value = "This is the default description"
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @package forms
|
||||
* @subpackage fields-basic
|
||||
*/
|
||||
class TextareaField extends FormField {
|
||||
|
||||
/**
|
||||
* @var int Visible number of text lines.
|
||||
* Visible number of text lines.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rows = 5;
|
||||
|
||||
/**
|
||||
* @var int Width of the text area (in average character widths)
|
||||
* Visible number of text columns.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $cols = 20;
|
||||
|
||||
/**
|
||||
* Set the number of rows in the textarea
|
||||
*
|
||||
* @param int $rows
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRows($rows) {
|
||||
$this->rows = $rows;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of columns in the textarea
|
||||
*
|
||||
* @param int $cols
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumns($cols) {
|
||||
$this->cols = $cols;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributes() {
|
||||
return array_merge(
|
||||
parent::getAttributes(),
|
||||
@ -42,30 +73,22 @@ class TextareaField extends FormField {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function Type() {
|
||||
return parent::Type() . ($this->readonly ? ' readonly' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of rows in the textarea
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setRows($rows) {
|
||||
$this->rows = $rows;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of columns in the textarea
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function setColumns($cols) {
|
||||
$this->cols = $cols;
|
||||
return $this;
|
||||
$parent = parent::Type();
|
||||
|
||||
if($this->readonly) {
|
||||
return $parent . ' readonly';
|
||||
}
|
||||
|
||||
return $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Value() {
|
||||
return htmlentities($this->value, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user