@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
3/**
4 * This provides the layout of an AphrontFormView without actually providing
5 * the <form /> tag. Useful on its own for creating forms in other forms (like
6 * dialogs) or forms which aren't submittable.
7 */
8final class PHUIFormLayoutView extends AphrontView {
9
10 private $classes = array();
11 private $fullWidth;
12
13 public function setFullWidth($width) {
14 $this->fullWidth = $width;
15 return $this;
16 }
17
18 public function addClass($class) {
19 $this->classes[] = $class;
20 return $this;
21 }
22
23 public function appendInstructions($text) {
24 return $this->appendChild(
25 phutil_tag(
26 'div',
27 array(
28 'class' => 'aphront-form-instructions',
29 ),
30 $text));
31 }
32
33 public function appendRemarkupInstructions($remarkup) {
34 $view = id(new AphrontFormView())
35 ->setViewer($this->getViewer())
36 ->newInstructionsRemarkupView($remarkup);
37
38 return $this->appendInstructions($view);
39 }
40
41 public function render() {
42 $classes = $this->classes;
43 $classes[] = 'phui-form-view';
44
45 if ($this->fullWidth) {
46 $classes[] = 'phui-form-full-width';
47 }
48
49 return phutil_tag(
50 'div',
51 array(
52 'class' => implode(' ', $classes),
53 ),
54 $this->renderChildren());
55
56 }
57}