public function renderControl() { $control = null; switch ($this->getFieldType()) { 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; default: throw new ManiphestAuxiliaryFieldTypeException($this->getFieldType() . ' is not a valid type for ' . $this->getLabel()); break; } $control->setValue($this->getValue()); $control->setLabel($this->getLabel()); $control->setCaption($this->getCaption()); $control->setName('auxiliary[' . $this->getAuxiliaryKey() . ']'); $control->setError($this->getError()); return $control; }
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; }