1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Let "<select />" EditEngine fields canonicalize saved defaults

Summary:
Ref T12124. After D18134 we accept either "25" or "low" via HTTP parameters and when the field renders as a control, but if the form has a default value for the field but locks or hides it we don't actually run through that logic.

Canonicalize both when rendering the control and when using a raw saved default value.

Test Plan:
  - Created a form with "Priority: Low".
  - Hid the "Priority" field.
  - Before patch: Tried to create a task, was rebuffed with a (now verbose and helpful, after D18135) error.
  - Applied patch: things worked.

Reviewers: chad, amckinley

Reviewed By: amckinley

Maniphest Tasks: T12124

Differential Revision: https://secure.phabricator.com/D18142
This commit is contained in:
epriestley 2017-06-20 15:20:41 -07:00
parent 17fc447503
commit 149e6aaa21

View file

@ -27,18 +27,13 @@ final class PhabricatorSelectEditField
return $this->optionAliases;
}
protected function getDefaultValueFromConfiguration($value) {
return $this->getCanonicalValue($value);
}
protected function getValueForControl() {
$value = parent::getValueForControl();
$options = $this->getOptions();
if (!isset($options[$value])) {
$aliases = $this->getOptionAliases();
if (isset($aliases[$value])) {
$value = $aliases[$value];
}
}
return $value;
return $this->getCanonicalValue($value);
}
protected function newControl() {
@ -59,4 +54,16 @@ final class PhabricatorSelectEditField
return new ConduitStringParameterType();
}
private function getCanonicalValue($value) {
$options = $this->getOptions();
if (!isset($options[$value])) {
$aliases = $this->getOptionAliases();
if (isset($aliases[$value])) {
$value = $aliases[$value];
}
}
return $value;
}
}