Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/form/control/AphrontFormTextAreaControl.php
12262 views
1
<?php
2
3
/**
4
* @concrete-extensible
5
*/
6
class AphrontFormTextAreaControl extends AphrontFormControl {
7
8
const HEIGHT_VERY_SHORT = 'very-short';
9
const HEIGHT_SHORT = 'short';
10
const HEIGHT_VERY_TALL = 'very-tall';
11
12
private $height;
13
private $readOnly;
14
private $customClass;
15
private $placeHolder;
16
private $sigil;
17
18
public function setSigil($sigil) {
19
$this->sigil = $sigil;
20
return $this;
21
}
22
23
public function getSigil() {
24
return $this->sigil;
25
}
26
27
public function setPlaceHolder($place_holder) {
28
$this->placeHolder = $place_holder;
29
return $this;
30
}
31
private function getPlaceHolder() {
32
return $this->placeHolder;
33
}
34
35
public function setHeight($height) {
36
$this->height = $height;
37
return $this;
38
}
39
40
public function setReadOnly($read_only) {
41
$this->readOnly = $read_only;
42
return $this;
43
}
44
45
protected function getReadOnly() {
46
return $this->readOnly;
47
}
48
49
protected function getCustomControlClass() {
50
return 'aphront-form-control-textarea';
51
}
52
53
public function setCustomClass($custom_class) {
54
$this->customClass = $custom_class;
55
return $this;
56
}
57
58
protected function renderInput() {
59
60
$height_class = null;
61
switch ($this->height) {
62
case self::HEIGHT_VERY_SHORT:
63
case self::HEIGHT_SHORT:
64
case self::HEIGHT_VERY_TALL:
65
$height_class = 'aphront-textarea-'.$this->height;
66
break;
67
}
68
69
$classes = array();
70
$classes[] = $height_class;
71
$classes[] = $this->customClass;
72
$classes = trim(implode(' ', $classes));
73
74
// NOTE: This needs to be string cast, because if we pass `null` the
75
// tag will be self-closed and some browsers aren't thrilled about that.
76
$value = phutil_string_cast($this->getValue());
77
78
// NOTE: We also need to prefix the string with a newline, because browsers
79
// ignore a newline immediately after a <textarea> tag, so they'll eat
80
// leading newlines if we don't do this. See T8707.
81
$value = "\n".$value;
82
83
return javelin_tag(
84
'textarea',
85
array(
86
'name' => $this->getName(),
87
'disabled' => $this->getDisabled() ? 'disabled' : null,
88
'readonly' => $this->getReadOnly() ? 'readonly' : null,
89
'class' => $classes,
90
'style' => $this->getControlStyle(),
91
'id' => $this->getID(),
92
'sigil' => $this->sigil,
93
'placeholder' => $this->getPlaceHolder(),
94
),
95
$value);
96
}
97
98
}
99
100