Path: blob/master/src/view/form/control/AphrontFormRadioButtonControl.php
12262 views
<?php12final class AphrontFormRadioButtonControl extends AphrontFormControl {34private $buttons = array();56public function addButton(7$value,8$label,9$caption,10$class = null,11$disabled = false) {12$this->buttons[] = array(13'value' => $value,14'label' => $label,15'caption' => $caption,16'class' => $class,17'disabled' => $disabled,18);19return $this;20}2122protected function getCustomControlClass() {23return 'aphront-form-control-radio';24}2526protected function renderInput() {27$rows = array();28foreach ($this->buttons as $button) {29$id = celerity_generate_unique_node_id();30$radio = phutil_tag(31'input',32array(33'id' => $id,34'type' => 'radio',35'name' => $this->getName(),36'value' => $button['value'],37'checked' => ($button['value'] == $this->getValue())38? 'checked'39: null,40'disabled' => ($this->getDisabled() || $button['disabled'])41? 'disabled'42: null,43));44$label = phutil_tag(45'label',46array(47'for' => $id,48'class' => $button['class'],49),50$button['label']);5152if ($button['caption']) {53$label = array(54$label,55phutil_tag_div('aphront-form-radio-caption', $button['caption']),56);57}58$rows[] = phutil_tag('tr', array(), array(59phutil_tag('td', array(), $radio),60phutil_tag('th', array(), $label),61));62}6364return phutil_tag(65'table',66array('class' => 'aphront-form-control-radio-layout'),67$rows);68}6970}717273