protected function newControl()
 {
     $value = array_fuse($this->getValue());
     $control = new AphrontFormCheckboxControl();
     foreach ($this->getOptions() as $key => $option) {
         $control->addCheckbox($this->getKey() . '[]', $key, $option, isset($value[$key]));
     }
     return $control;
 }
 public static function getCheckboxControl($current_scopes)
 {
     $scopes = self::getScopesDict();
     $scope_keys = array_keys($scopes);
     sort($scope_keys);
     $checkboxes = new AphrontFormCheckboxControl();
     foreach ($scope_keys as $scope) {
         $checkboxes->addCheckbox($name = $scope, $value = 1, $label = self::getCheckboxLabel($scope), $checked = isset($current_scopes[$scope]));
     }
     $checkboxes->setLabel('Scope');
     return $checkboxes;
 }
 public static function getCheckboxControl(array $current_scopes)
 {
     $have_options = false;
     $scopes = self::getScopesDict();
     $scope_keys = array_keys($scopes);
     sort($scope_keys);
     $default_scope = self::getDefaultScope();
     $checkboxes = new AphrontFormCheckboxControl();
     foreach ($scope_keys as $scope) {
         if ($scope == $default_scope) {
             continue;
         }
         if (!isset($current_scopes[$scope])) {
             continue;
         }
         $checkboxes->addCheckbox($name = $scope, $value = 1, $label = self::getCheckboxLabel($scope), $checked = isset($current_scopes[$scope]));
         $have_options = true;
     }
     if ($have_options) {
         $checkboxes->setLabel(pht('Scope'));
         return $checkboxes;
     }
     return null;
 }
 public function renderControl()
 {
     $control = null;
     $type = $this->getFieldType();
     switch ($type) {
         case self::TYPE_INT:
             $control = new AphrontFormTextControl();
             break;
         case self::TYPE_STRING:
             $control = new AphrontFormTextControl();
             break;
         case self::TYPE_SELECT:
             $control = new AphrontFormSelectControl();
             $control->setOptions($this->getSelectOptions());
             break;
         case self::TYPE_BOOL:
             $control = new AphrontFormCheckboxControl();
             break;
         default:
             $label = $this->getLabel();
             throw new ManiphestAuxiliaryFieldTypeException("Field type '{$type}' is not a valid type (for field '{$label}').");
             break;
     }
     if ($type == self::TYPE_BOOL) {
         $control->addCheckbox('auxiliary[' . $this->getAuxiliaryKey() . ']', 1, $this->getCheckboxLabel(), (bool) $this->getValue());
     } else {
         $control->setValue($this->getValue());
         $control->setName('auxiliary[' . $this->getAuxiliaryKey() . ']');
     }
     $control->setLabel($this->getLabel());
     $control->setCaption($this->getCaption());
     $control->setError($this->getError());
     return $control;
 }
 private function buildMailTagCheckboxes(array $tags, array $prefs)
 {
     $control = new AphrontFormCheckboxControl();
     foreach ($tags as $key => $label) {
         $control->addCheckbox('mailtags[' . $key . ']', 1, $label, idx($prefs, $key, 1));
     }
     return $control;
 }