Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / view / form / control / AphrontFormRadioButtonControl.php
blob5764275151845af3aaab64d738df4e5f4667db20
1 <?php
3 final class AphrontFormRadioButtonControl extends AphrontFormControl {
5 private $buttons = array();
7 public function addButton(
8 $value,
9 $label,
10 $caption,
11 $class = null,
12 $disabled = false) {
13 $this->buttons[] = array(
14 'value' => $value,
15 'label' => $label,
16 'caption' => $caption,
17 'class' => $class,
18 'disabled' => $disabled,
20 return $this;
23 protected function getCustomControlClass() {
24 return 'aphront-form-control-radio';
27 protected function renderInput() {
28 $rows = array();
29 foreach ($this->buttons as $button) {
30 $id = celerity_generate_unique_node_id();
31 $radio = phutil_tag(
32 'input',
33 array(
34 'id' => $id,
35 'type' => 'radio',
36 'name' => $this->getName(),
37 'value' => $button['value'],
38 'checked' => ($button['value'] == $this->getValue())
39 ? 'checked'
40 : null,
41 'disabled' => ($this->getDisabled() || $button['disabled'])
42 ? 'disabled'
43 : null,
44 ));
45 $label = phutil_tag(
46 'label',
47 array(
48 'for' => $id,
49 'class' => $button['class'],
51 $button['label']);
53 if ($button['caption']) {
54 $label = array(
55 $label,
56 phutil_tag_div('aphront-form-radio-caption', $button['caption']),
59 $rows[] = phutil_tag('tr', array(), array(
60 phutil_tag('td', array(), $radio),
61 phutil_tag('th', array(), $label),
62 ));
65 return phutil_tag(
66 'table',
67 array('class' => 'aphront-form-control-radio-layout'),
68 $rows);