@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
1<?php
2
3final class PHUIFormNumberControl extends AphrontFormControl {
4
5 private $disableAutocomplete;
6 private $autofocus;
7 private $readOnly;
8
9 public function setDisableAutocomplete($disable_autocomplete) {
10 $this->disableAutocomplete = $disable_autocomplete;
11 return $this;
12 }
13
14 public function getDisableAutocomplete() {
15 return $this->disableAutocomplete;
16 }
17
18 public function setAutofocus($autofocus) {
19 $this->autofocus = $autofocus;
20 return $this;
21 }
22
23 public function getAutofocus() {
24 return $this->autofocus;
25 }
26
27 public function setReadOnly($read_only) {
28 $this->readOnly = $read_only;
29 return $this;
30 }
31
32 protected function getReadOnly() {
33 return $this->readOnly;
34 }
35
36 protected function getCustomControlClass() {
37 return 'phui-form-number';
38 }
39
40 protected function renderInput() {
41 if ($this->getDisableAutocomplete()) {
42 $autocomplete = 'off';
43 } else {
44 $autocomplete = null;
45 }
46
47 return javelin_tag(
48 'input',
49 array(
50 'type' => 'text',
51 'pattern' => '\d*',
52 'name' => $this->getName(),
53 'value' => $this->getValue(),
54 'disabled' => $this->getDisabled() ? 'disabled' : null,
55 'readonly' => $this->getReadOnly() ? 'readonly' : null,
56 'autocomplete' => $autocomplete,
57 'id' => $this->getID(),
58 'autofocus' => ($this->getAutofocus() ? 'autofocus' : null),
59 ));
60 }
61
62}