From 45ff6077a7c722b0748fe76c16bcf4e28aa05893 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 19 Sep 2013 11:55:28 -0700 Subject: [PATCH] Allow standard fields to have defaults Summary: Final standard capability from Maniphest fields. Test Plan: This isn't really reachable now since users always exist, but faked it and verified the field prefilled as expected. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7033 --- .../customfield/field/PhabricatorCustomFieldList.php | 5 ++++- .../customfield/standard/PhabricatorStandardCustomField.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php index bb1c445bec..bb030154d1 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php @@ -27,6 +27,7 @@ final class PhabricatorCustomFieldList extends Phobject { return $this; } + /** * Read stored values for all fields which support storage. * @@ -65,7 +66,9 @@ final class PhabricatorCustomFieldList extends Phobject { $storage = idx($objects, $key); if ($storage) { $field->setValueFromStorage($storage->getFieldValue()); - } else { + } else if ($object->getPHID()) { + // NOTE: We set this only if the object exists. Otherwise, we allow the + // field to retain any default value it may have. $field->setValueFromStorage(null); } } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php index 7d73234655..2f79bfd22b 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -108,6 +108,9 @@ abstract class PhabricatorStandardCustomField $this->setRequired($value); $this->setFieldError(true); break; + case 'default': + $this->setFieldValue($value); + break; case 'type': // We set this earlier on. break;