mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Allow standard date fields to read default dates as strings
Summary: Ref T2217. Fixes T3866. We need to do a little more massaging before we can set strings as the value on datetime controls. Test Plan: Set default to "1:23 AM", "2001/02/03". Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217, T3866 Differential Revision: https://secure.phabricator.com/D7116
This commit is contained in:
parent
6d45a2e09b
commit
bef6d82cce
1 changed files with 12 additions and 1 deletions
|
@ -65,7 +65,18 @@ final class PhabricatorStandardCustomFieldDate
|
|||
->setCaption($this->getCaption())
|
||||
->setAllowNull(!$this->getRequired());
|
||||
|
||||
$control->setValue($this->getFieldValue());
|
||||
// If the value is already numeric, treat it as an epoch timestamp and set
|
||||
// it directly. Otherwise, it's likely a field default, which we let users
|
||||
// specify as a string. Parse the string into an epoch.
|
||||
|
||||
$value = $this->getFieldValue();
|
||||
if (!ctype_digit($value)) {
|
||||
$value = PhabricatorTime::parseLocalTime($value, $this->getViewer());
|
||||
}
|
||||
|
||||
// If we don't have anything valid, make sure we pass `null`, since the
|
||||
// control special-cases that.
|
||||
$control->setValue(nonempty($value, null));
|
||||
|
||||
return $control;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue