Page MenuHomePhorge

D25740.1734643191.diff
No OneTemporary

D25740.1734643191.diff

diff --git a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
--- a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
@@ -7,6 +7,8 @@
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$xactions = array();
+ $errors = array();
+ $e_recipient = true;
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
@@ -29,24 +31,29 @@
$add_recipients = $request->getArr('phids');
if ($add_recipients) {
foreach ($add_recipients as $phid) {
- $award_phids[] = $phid;
+ $award_phids[$phid] = $phid;
}
+ } else {
+ $errors[] = pht('Recipient name is required.');
+ $e_recipient = pht('Required');
}
- $xactions[] = id(new PhabricatorBadgesTransaction())
- ->setTransactionType(
- PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
- ->setNewValue($award_phids);
+ if (!$errors) {
+ $xactions[] = id(new PhabricatorBadgesTransaction())
+ ->setTransactionType(
+ PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE)
+ ->setNewValue($award_phids);
- $editor = id(new PhabricatorBadgesEditor())
- ->setActor($viewer)
- ->setContentSourceFromRequest($request)
- ->setContinueOnNoEffect(true)
- ->setContinueOnMissingFields(true)
- ->applyTransactions($badge, $xactions);
+ $editor = id(new PhabricatorBadgesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($badge, $xactions);
- return id(new AphrontRedirectResponse())
- ->setURI($view_uri);
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
}
$form = new AphrontFormView();
@@ -57,6 +64,7 @@
id(new AphrontFormTokenizerControl())
->setName('phids')
->setLabel(pht('Recipients'))
+ ->setError($e_recipient)
->setDatasource(new PhabricatorPeopleDatasource()));
$dialog = id(new AphrontDialogView())

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 21:19 (2 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015636
Default Alt Text
D25740.1734643191.diff (2 KB)

Event Timeline