Skip to content

Commit

Permalink
Merge pull request #22359 from colemanw/api4ActivityCreate
Browse files Browse the repository at this point in the history
APIv4 - Set 'activity_type_id' to required
  • Loading branch information
eileenmcnaughton authored Jan 3, 2022
2 parents 056d0b3 + ea6fbf7 commit 1793196
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Civi/Api4/Service/Spec/Provider/ActivitySpecProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class ActivitySpecProvider implements Generic\SpecProviderInterface {
public function modifySpec(RequestSpec $spec) {
$action = $spec->getAction();

// The database default '1' is problematic as the option list is user-configurable,
// so activity type '1' doesn't necessarily exist. Best make the field required.
$spec->getFieldByName('activity_type_id')
->setDefaultValue(NULL)
->setRequired($action === 'create');

$field = new FieldSpec('source_contact_id', 'Activity', 'Integer');
$field->setTitle(ts('Source Contact'));
$field->setLabel(ts('Added by'));
Expand Down

0 comments on commit 1793196

Please sign in to comment.