summaryrefslogtreecommitdiff
path: root/includes/htmlform/HTMLTextAreaField.php
blob: 21173d2a630f8313cc2607146b58ca9b6b5ac143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class HTMLTextAreaField extends HTMLFormField {
	const DEFAULT_COLS = 80;
	const DEFAULT_ROWS = 25;

	function getCols() {
		return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
	}

	function getRows() {
		return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
	}

	function getInputHTML( $value ) {
		$attribs = array(
				'id' => $this->mID,
				'cols' => $this->getCols(),
				'rows' => $this->getRows(),
			) + $this->getTooltipAndAccessKey();

		if ( $this->mClass !== '' ) {
			$attribs['class'] = $this->mClass;
		}

		$allowedParams = array(
			'placeholder',
			'tabindex',
			'disabled',
			'readonly',
			'required',
			'autofocus'
		);

		$attribs += $this->getAttributes( $allowedParams );
		return Html::textarea( $this->mName, $value, $attribs );
	}
}