protected function buildCustomEditFields($object)
 {
     $viewer = $this->getViewer();
     if ($this->getIsCreate()) {
         $invitee_phids = array($viewer->getPHID());
     } else {
         $invitee_phids = $object->getInviteePHIDsForEdit();
     }
     $frequency_map = PhabricatorCalendarEvent::getFrequencyMap();
     $frequency_options = ipull($frequency_map, 'label');
     $rrule = $object->newRecurrenceRule();
     if ($rrule) {
         $frequency = $rrule->getFrequency();
     } else {
         $frequency = null;
     }
     // At least for now, just hide "Invitees" when editing all future events.
     // This may eventually deserve a more nuanced approach.
     $is_future = $this->getSeriesEditMode() == self::MODE_FUTURE;
     $fields = array(id(new PhabricatorTextEditField())->setKey('name')->setLabel(pht('Name'))->setDescription(pht('Name of the event.'))->setIsRequired(true)->setTransactionType(PhabricatorCalendarEventNameTransaction::TRANSACTIONTYPE)->setConduitDescription(pht('Rename the event.'))->setConduitTypeDescription(pht('New event name.'))->setValue($object->getName()), id(new PhabricatorBoolEditField())->setIsLockable(false)->setIsDefaultable(false)->setKey('isAllDay')->setOptions(pht('Normal Event'), pht('All Day Event'))->setAsCheckbox(true)->setTransactionType(PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE)->setDescription(pht('Marks this as an all day event.'))->setConduitDescription(pht('Make the event an all day event.'))->setConduitTypeDescription(pht('Mark the event as an all day event.'))->setValue($object->getIsAllDay()), id(new PhabricatorEpochEditField())->setKey('start')->setLabel(pht('Start'))->setIsLockable(false)->setIsDefaultable(false)->setTransactionType(PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE)->setDescription(pht('Start time of the event.'))->setConduitDescription(pht('Change the start time of the event.'))->setConduitTypeDescription(pht('New event start time.'))->setValue($object->getStartDateTimeEpoch()), id(new PhabricatorEpochEditField())->setKey('end')->setLabel(pht('End'))->setIsLockable(false)->setIsDefaultable(false)->setTransactionType(PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE)->setDescription(pht('End time of the event.'))->setConduitDescription(pht('Change the end time of the event.'))->setConduitTypeDescription(pht('New event end time.'))->setValue($object->newEndDateTimeForEdit()->getEpoch()), id(new PhabricatorBoolEditField())->setKey('cancelled')->setOptions(pht('Active'), pht('Cancelled'))->setLabel(pht('Cancelled'))->setDescription(pht('Cancel the event.'))->setTransactionType(PhabricatorCalendarEventCancelTransaction::TRANSACTIONTYPE)->setIsConduitOnly(true)->setConduitDescription(pht('Cancel or restore the event.'))->setConduitTypeDescription(pht('True to cancel the event.'))->setValue($object->getIsCancelled()), id(new PhabricatorUsersEditField())->setIsLockable(false)->setIsDefaultable(false)->setKey('hostPHID')->setAliases(array('host'))->setLabel(pht('Host'))->setDescription(pht('Host of the event.'))->setTransactionType(PhabricatorCalendarEventHostTransaction::TRANSACTIONTYPE)->setIsConduitOnly($this->getIsCreate())->setConduitDescription(pht('Change the host of the event.'))->setConduitTypeDescription(pht('New event host.'))->setSingleValue($object->getHostPHID()), id(new PhabricatorDatasourceEditField())->setIsLockable(false)->setIsDefaultable(false)->setIsHidden($is_future)->setKey('inviteePHIDs')->setAliases(array('invite', 'invitee', 'invitees', 'inviteePHID'))->setLabel(pht('Invitees'))->setDatasource(new PhabricatorMetaMTAMailableDatasource())->setTransactionType(PhabricatorCalendarEventInviteTransaction::TRANSACTIONTYPE)->setDescription(pht('Users invited to the event.'))->setConduitDescription(pht('Change invited users.'))->setConduitTypeDescription(pht('New event invitees.'))->setValue($invitee_phids)->setCommentActionLabel(pht('Change Invitees')), id(new PhabricatorRemarkupEditField())->setKey('description')->setLabel(pht('Description'))->setDescription(pht('Description of the event.'))->setTransactionType(PhabricatorCalendarEventDescriptionTransaction::TRANSACTIONTYPE)->setConduitDescription(pht('Update the event description.'))->setConduitTypeDescription(pht('New event description.'))->setValue($object->getDescription()), id(new PhabricatorIconSetEditField())->setKey('icon')->setLabel(pht('Icon'))->setIconSet(new PhabricatorCalendarIconSet())->setTransactionType(PhabricatorCalendarEventIconTransaction::TRANSACTIONTYPE)->setDescription(pht('Event icon.'))->setConduitDescription(pht('Change the event icon.'))->setConduitTypeDescription(pht('New event icon.'))->setValue($object->getIcon()), id(new PhabricatorBoolEditField())->setIsHidden(true)->setIsLockable(false)->setIsDefaultable(false)->setKey('isRecurring')->setLabel(pht('Recurring'))->setOptions(pht('One-Time Event'), pht('Recurring Event'))->setTransactionType(PhabricatorCalendarEventRecurringTransaction::TRANSACTIONTYPE)->setDescription(pht('One time or recurring event.'))->setConduitDescription(pht('Make the event recurring.'))->setConduitTypeDescription(pht('Mark the event as a recurring event.'))->setValue(true), id(new PhabricatorSelectEditField())->setIsLockable(false)->setIsDefaultable(false)->setKey('frequency')->setLabel(pht('Frequency'))->setOptions($frequency_options)->setTransactionType(PhabricatorCalendarEventFrequencyTransaction::TRANSACTIONTYPE)->setDescription(pht('Recurring event frequency.'))->setConduitDescription(pht('Change the event frequency.'))->setConduitTypeDescription(pht('New event frequency.'))->setValue($frequency), id(new PhabricatorEpochEditField())->setIsLockable(false)->setIsDefaultable(false)->setAllowNull(true)->setHideTime($object->getIsAllDay())->setKey('until')->setLabel(pht('Repeat Until'))->setTransactionType(PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE)->setDescription(pht('Last instance of the event.'))->setConduitDescription(pht('Change when the event repeats until.'))->setConduitTypeDescription(pht('New final event time.'))->setValue($object->getUntilDateTimeEpoch()));
     return $fields;
 }