2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2015-04-27 05:15:32 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2008-10-20 12:05:05 +02:00
|
|
|
* 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.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2010-10-15 05:55:22 +02:00
|
|
|
* <code>
|
|
|
|
* new TextareaField(
|
|
|
|
* $name = "description",
|
|
|
|
* $title = "Description",
|
|
|
|
* $value = "This is the default description"
|
|
|
|
* );
|
|
|
|
* </code>
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-basic
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class TextareaField extends FormField {
|
2016-11-14 23:55:48 +01:00
|
|
|
|
|
|
|
private static $casting = array(
|
2016-12-16 04:51:15 +01:00
|
|
|
'Value' => 'HTMLText(array("shortcodes" => 0))',
|
2016-11-14 23:55:48 +01:00
|
|
|
);
|
|
|
|
|
2012-02-10 12:15:21 +01:00
|
|
|
/**
|
2015-04-27 05:15:32 +02:00
|
|
|
* Visible number of text lines.
|
|
|
|
*
|
|
|
|
* @var int
|
2012-02-10 12:15:21 +01:00
|
|
|
*/
|
|
|
|
protected $rows = 5;
|
|
|
|
|
|
|
|
/**
|
2015-04-27 05:15:32 +02:00
|
|
|
* Visible number of text columns.
|
|
|
|
*
|
|
|
|
* @var int
|
2012-02-10 12:15:21 +01:00
|
|
|
*/
|
|
|
|
protected $cols = 20;
|
2011-03-23 05:12:25 +01:00
|
|
|
|
2010-10-15 04:56:36 +02:00
|
|
|
/**
|
|
|
|
* Set the number of rows in the textarea
|
|
|
|
*
|
2015-04-27 05:15:32 +02:00
|
|
|
* @param int $rows
|
|
|
|
*
|
|
|
|
* @return $this
|
2010-10-15 04:56:36 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function setRows($rows) {
|
2010-10-15 04:56:36 +02:00
|
|
|
$this->rows = $rows;
|
2015-04-27 05:15:32 +02:00
|
|
|
|
2012-02-17 13:35:26 +01:00
|
|
|
return $this;
|
2010-10-15 04:56:36 +02:00
|
|
|
}
|
2015-04-27 05:15:32 +02:00
|
|
|
|
2010-10-15 04:56:36 +02:00
|
|
|
/**
|
|
|
|
* Set the number of columns in the textarea
|
|
|
|
*
|
2015-04-27 05:15:32 +02:00
|
|
|
* @param int $cols
|
|
|
|
*
|
|
|
|
* @return $this
|
2010-10-15 04:56:36 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function setColumns($cols) {
|
2010-10-15 04:56:36 +02:00
|
|
|
$this->cols = $cols;
|
2015-04-27 05:15:32 +02:00
|
|
|
|
2012-02-17 13:35:26 +01:00
|
|
|
return $this;
|
2010-10-15 04:56:36 +02:00
|
|
|
}
|
2011-12-22 13:10:57 +01:00
|
|
|
|
2015-04-27 05:15:32 +02:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getAttributes() {
|
2011-12-22 13:10:57 +01:00
|
|
|
return array_merge(
|
|
|
|
parent::getAttributes(),
|
2011-03-23 05:12:25 +01:00
|
|
|
array(
|
2011-12-22 13:10:57 +01:00
|
|
|
'rows' => $this->rows,
|
|
|
|
'cols' => $this->cols,
|
|
|
|
'value' => null,
|
|
|
|
'type' => null
|
2011-03-23 05:12:25 +01:00
|
|
|
)
|
|
|
|
);
|
2007-08-13 13:54:44 +02:00
|
|
|
}
|
2011-03-23 05:12:25 +01:00
|
|
|
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-15 04:56:36 +02:00
|
|
|
/**
|
2015-04-27 05:15:32 +02:00
|
|
|
* {@inheritdoc}
|
2010-10-15 04:56:36 +02:00
|
|
|
*/
|
2015-04-27 05:15:32 +02:00
|
|
|
public function Type() {
|
|
|
|
$parent = parent::Type();
|
|
|
|
|
|
|
|
if($this->readonly) {
|
|
|
|
return $parent . ' readonly';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $parent;
|
2010-10-15 04:56:36 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-15 04:56:36 +02:00
|
|
|
/**
|
2015-04-27 05:15:32 +02:00
|
|
|
* @return string
|
2010-10-15 04:56:36 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function Value() {
|
2011-12-22 13:10:57 +01:00
|
|
|
return htmlentities($this->value, ENT_COMPAT, 'UTF-8');
|
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|