[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/form/control/ -> AphrontFormCheckboxControl.php (source)

   1  <?php
   2  
   3  final class AphrontFormCheckboxControl extends AphrontFormControl {
   4  
   5    private $boxes = array();
   6  
   7    public function addCheckbox($name, $value, $label, $checked = false) {
   8      $this->boxes[] = array(
   9        'name'    => $name,
  10        'value'   => $value,
  11        'label'   => $label,
  12        'checked' => $checked,
  13      );
  14      return $this;
  15    }
  16  
  17    protected function getCustomControlClass() {
  18      return 'aphront-form-control-checkbox';
  19    }
  20  
  21    protected function renderInput() {
  22      $rows = array();
  23      foreach ($this->boxes as $box) {
  24        $id = celerity_generate_unique_node_id();
  25        $checkbox = phutil_tag(
  26          'input',
  27          array(
  28            'id' => $id,
  29            'type' => 'checkbox',
  30            'name' => $box['name'],
  31            'value' => $box['value'],
  32            'checked' => $box['checked'] ? 'checked' : null,
  33            'disabled' => $this->getDisabled() ? 'disabled' : null,
  34          ));
  35        $label = phutil_tag(
  36          'label',
  37          array(
  38            'for' => $id,
  39          ),
  40          $box['label']);
  41        $rows[] = phutil_tag('tr', array(), array(
  42          phutil_tag('td', array(), $checkbox),
  43          phutil_tag('th', array(), $label),
  44        ));
  45      }
  46      return phutil_tag(
  47        'table',
  48        array('class' => 'aphront-form-control-checkbox-layout'),
  49        $rows);
  50    }
  51  
  52  }


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