Path: blob/master/src/view/form/control/AphrontFormTextAreaControl.php
12262 views
<?php12/**3* @concrete-extensible4*/5class AphrontFormTextAreaControl extends AphrontFormControl {67const HEIGHT_VERY_SHORT = 'very-short';8const HEIGHT_SHORT = 'short';9const HEIGHT_VERY_TALL = 'very-tall';1011private $height;12private $readOnly;13private $customClass;14private $placeHolder;15private $sigil;1617public function setSigil($sigil) {18$this->sigil = $sigil;19return $this;20}2122public function getSigil() {23return $this->sigil;24}2526public function setPlaceHolder($place_holder) {27$this->placeHolder = $place_holder;28return $this;29}30private function getPlaceHolder() {31return $this->placeHolder;32}3334public function setHeight($height) {35$this->height = $height;36return $this;37}3839public function setReadOnly($read_only) {40$this->readOnly = $read_only;41return $this;42}4344protected function getReadOnly() {45return $this->readOnly;46}4748protected function getCustomControlClass() {49return 'aphront-form-control-textarea';50}5152public function setCustomClass($custom_class) {53$this->customClass = $custom_class;54return $this;55}5657protected function renderInput() {5859$height_class = null;60switch ($this->height) {61case self::HEIGHT_VERY_SHORT:62case self::HEIGHT_SHORT:63case self::HEIGHT_VERY_TALL:64$height_class = 'aphront-textarea-'.$this->height;65break;66}6768$classes = array();69$classes[] = $height_class;70$classes[] = $this->customClass;71$classes = trim(implode(' ', $classes));7273// NOTE: This needs to be string cast, because if we pass `null` the74// tag will be self-closed and some browsers aren't thrilled about that.75$value = phutil_string_cast($this->getValue());7677// NOTE: We also need to prefix the string with a newline, because browsers78// ignore a newline immediately after a <textarea> tag, so they'll eat79// leading newlines if we don't do this. See T8707.80$value = "\n".$value;8182return javelin_tag(83'textarea',84array(85'name' => $this->getName(),86'disabled' => $this->getDisabled() ? 'disabled' : null,87'readonly' => $this->getReadOnly() ? 'readonly' : null,88'class' => $classes,89'style' => $this->getControlStyle(),90'id' => $this->getID(),91'sigil' => $this->sigil,92'placeholder' => $this->getPlaceHolder(),93),94$value);95}9697}9899100