Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / view / form / control / AphrontFormHandlesControl.php
blobb7b4c2de1c33822d7bba8f6da513bc11eb0c031d
1 <?php
3 final class AphrontFormHandlesControl extends AphrontFormControl {
5 private $isInvisible;
7 protected function getCustomControlClass() {
8 return 'aphront-form-control-handles';
11 public function setIsInvisible($is_invisible) {
12 $this->isInvisible = $is_invisible;
13 return $this;
16 public function getIsInvisible() {
17 return $this->isInvisible;
20 protected function shouldRender() {
21 return (bool)$this->getValue();
24 public function getLabel() {
25 // TODO: This is a bit funky and still rendering a few pixels of padding
26 // on the form, but there's currently no way to get a control to only emit
27 // hidden inputs. Clean this up eventually.
29 if ($this->getIsInvisible()) {
30 return null;
33 return parent::getLabel();
36 protected function renderInput() {
37 $value = $this->getValue();
38 $viewer = $this->getUser();
40 $out = array();
42 if (!$this->getIsInvisible()) {
43 $list = $viewer->renderHandleList($value);
44 $list = id(new PHUIBoxView())
45 ->addPadding(PHUI::PADDING_SMALL_TOP)
46 ->appendChild($list);
47 $out[] = $list;
50 $inputs = array();
51 foreach ($value as $phid) {
52 $inputs[] = phutil_tag(
53 'input',
54 array(
55 'type' => 'hidden',
56 'name' => $this->getName().'[]',
57 'value' => $phid,
58 ));
60 $out[] = $inputs;
62 return $out;