Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114<?php
/** * @concrete-extensible */class AphrontFormTextAreaControl extends AphrontFormControl {
const HEIGHT_VERY_SHORT = 'very-short'; const HEIGHT_SHORT = 'short'; const HEIGHT_VERY_TALL = 'very-tall';
private $height; private $readOnly; private $customClass; private $placeHolder; private $sigil;
public function setSigil($sigil) { $this->sigil = $sigil; return $this; }
public function getSigil() { return $this->sigil; }
public function setPlaceHolder($place_holder) { $this->placeHolder = $place_holder; return $this; } private function getPlaceHolder() { return $this->placeHolder; }
/** * @param string $height One of the AphrontFormTextAreaControl::HEIGHT_* * variables */ public function setHeight($height) { $this->height = $height; return $this; }
public function setReadOnly($read_only) { $this->readOnly = $read_only; return $this; }
protected function getReadOnly() { return $this->readOnly; }
protected function getCustomControlClass() { return 'aphront-form-control-textarea'; }
public function setCustomClass($custom_class) { $this->customClass = $custom_class; return $this; }
/** * @return PhutilSafeHTML HTML textarea element */ protected function renderInput() {
$height_class = null; switch ($this->height) { case self::HEIGHT_VERY_SHORT: case self::HEIGHT_SHORT: case self::HEIGHT_VERY_TALL: $height_class = 'aphront-textarea-'.$this->height; break; }
$classes = array(); $classes[] = $height_class; $classes[] = $this->customClass; $classes = trim(implode(' ', $classes));
// NOTE: This needs to be string cast, because if we pass `null` the // tag will be self-closed and some browsers aren't thrilled about that. $value = phutil_string_cast($this->getValue());
// NOTE: We also need to prefix the string with a newline, because browsers // ignore a newline immediately after a <textarea> tag, so they'll eat // leading newlines if we don't do this. See T8707. $value = "\n".$value;
// Prefer the corresponding textarea "label" as "aria-label". If an element // does not have one, fall back to element "name". $aria_label = $this->getLabel(); if (!phutil_nonempty_string($aria_label)) { $aria_label = $this->getName(); }
return javelin_tag( 'textarea', array( 'name' => $this->getName(), 'aria-label' => $aria_label, 'disabled' => $this->getDisabled() ? 'disabled' : null, 'readonly' => $this->getReadOnly() ? 'readonly' : null, 'class' => $classes, 'style' => $this->getControlStyle(), 'id' => $this->getID(), 'sigil' => $this->sigil, 'placeholder' => $this->getPlaceHolder(), ), $value); }
}