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) @@ -31,22 +33,27 @@ foreach ($add_recipients as $phid) { $award_phids[] = $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())