[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/form/ -> PHUIFormLayoutView.php (source)

   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   */
   8  final class PHUIFormLayoutView extends AphrontView {
   9  
  10    private $fullWidth;
  11  
  12    public function setFullWidth($width) {
  13      $this->fullWidth = $width;
  14      return $this;
  15    }
  16  
  17    public function appendInstructions($text) {
  18      return $this->appendChild(
  19        phutil_tag(
  20          'div',
  21          array(
  22            'class' => 'aphront-form-instructions',
  23          ),
  24          $text));
  25    }
  26  
  27    public function appendRemarkupInstructions($remarkup) {
  28      if ($this->getUser() === null) {
  29        throw new Exception(
  30          'Call `setUser` before appending Remarkup to PHUIFormLayoutView.');
  31      }
  32  
  33      return $this->appendInstructions(
  34        PhabricatorMarkupEngine::renderOneObject(
  35          id(new PhabricatorMarkupOneOff())->setContent($remarkup),
  36          'default',
  37          $this->getUser()));
  38    }
  39  
  40    public function render() {
  41      $classes = array('phui-form-view');
  42  
  43      if ($this->fullWidth) {
  44        $classes[] = 'phui-form-full-width';
  45      }
  46  
  47      return phutil_tag(
  48        'div',
  49        array(
  50          'class' => implode(' ', $classes),
  51        ),
  52        $this->renderChildren());
  53  
  54    }
  55  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1