Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/setting/PhabricatorSelectSetting.php
| Show All 21 Lines | if (empty($options[''])) { | ||||
| '' => $default_label, | '' => $default_label, | ||||
| ) + $options; | ) + $options; | ||||
| } | } | ||||
| return $this->newEditField($object, new PhabricatorSelectEditField()) | return $this->newEditField($object, new PhabricatorSelectEditField()) | ||||
| ->setOptions($options); | ->setOptions($options); | ||||
| } | } | ||||
| public function assertValidValue($value) { | |||||
| // This is a slightly stricter check than the transaction check. It's | |||||
| // OK for empty string to go through transactions because it gets converted | |||||
| // to null later, but we shouldn't be reading the empty string from | |||||
| // storage. | |||||
| if ($value === null) { | |||||
| return; | |||||
| } | |||||
| if (!strlen($value)) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Empty string is not a valid setting for "%s".', | |||||
| $this->getSettingName())); | |||||
| } | |||||
| $this->validateTransactionValue($value); | |||||
| } | |||||
| final public function validateTransactionValue($value) { | final public function validateTransactionValue($value) { | ||||
| if (!strlen($value)) { | if (!strlen($value)) { | ||||
| return; | return; | ||||
| } | } | ||||
| $options = $this->getSelectOptions(); | $options = $this->getSelectOptions(); | ||||
| if (!isset($options[$value])) { | if (!isset($options[$value])) { | ||||
| Show All 20 Lines | |||||