@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 HeraldSelectFieldValue
4 extends HeraldFieldValue {
5
6 private $key;
7 private $options;
8 private $default;
9
10 public function setKey($key) {
11 $this->key = $key;
12 return $this;
13 }
14
15 public function getKey() {
16 return $this->key;
17 }
18
19 public function setOptions(array $options) {
20 $this->options = $options;
21 return $this;
22 }
23
24 public function getOptions() {
25 return $this->options;
26 }
27
28 public function setDefault($default) {
29 $this->default = $default;
30 return $this;
31 }
32
33 public function getDefault() {
34 return $this->default;
35 }
36
37 public function getFieldValueKey() {
38 if ($this->getKey() === null) {
39 throw new PhutilInvalidStateException('setKey');
40 }
41 return 'select.'.$this->getKey();
42 }
43
44 public function getControlType() {
45 return self::CONTROL_SELECT;
46 }
47
48 protected function getControlTemplate() {
49 if ($this->getOptions() === null) {
50 throw new PhutilInvalidStateException('setOptions');
51 }
52
53 return array(
54 'options' => $this->getOptions(),
55 'default' => $this->getDefault(),
56 );
57 }
58
59 public function renderFieldValue($value) {
60 $options = $this->getOptions();
61 return idx($options, $value, $value);
62 }
63
64 public function renderEditorValue($value) {
65 return $value;
66 }
67
68}