@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow standard fields to be required

Summary: Ref T418.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T418

Differential Revision: https://secure.phabricator.com/D7030

+42
+42
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
··· 12 12 private $strings; 13 13 private $caption; 14 14 private $fieldError; 15 + private $required; 16 + private $default; 15 17 16 18 abstract public function getFieldType(); 17 19 ··· 102 104 case 'caption': 103 105 $this->setCaption($value); 104 106 break; 107 + case 'required': 108 + $this->setRequired($value); 109 + $this->setFieldError(true); 110 + break; 105 111 case 'type': 106 112 // We set this earlier on. 107 113 break; ··· 124 130 return $this->fieldError; 125 131 } 126 132 133 + public function setRequired($required) { 134 + $this->required = $required; 135 + return $this; 136 + } 137 + 138 + public function getRequired() { 139 + return $this->required; 140 + } 141 + 127 142 128 143 /* -( PhabricatorCustomField )--------------------------------------------- */ 129 144 ··· 252 267 $type, 253 268 $xactions); 254 269 270 + if ($this->getRequired()) { 271 + $value = null; 272 + $transaction = null; 273 + foreach ($xactions as $xaction) { 274 + $value = $xaction->getNewValue(); 275 + if (!$this->isValueEmpty($value)) { 276 + $transaction = $xaction; 277 + break; 278 + } 279 + } 280 + if ($this->isValueEmpty($value)) { 281 + $errors[] = new PhabricatorApplicationTransactionValidationError( 282 + $type, 283 + pht('Required'), 284 + pht('%s is required.', $this->getFieldName()), 285 + $transaction); 286 + $this->setFieldError(pht('Required')); 287 + } 288 + } 289 + 255 290 return $errors; 291 + } 292 + 293 + protected function isValueEmpty($value) { 294 + if (is_array($value)) { 295 + return empty($value); 296 + } 297 + return !strlen($value); 256 298 } 257 299 258 300 }