Skip to content

Commit

Permalink
Issue backdrop-contrib#48: Add hook_field_insert() to remove empty ta…
Browse files Browse the repository at this point in the history
…rget_id when there are multiple.
  • Loading branch information
Jen Lampton committed Jun 25, 2021
1 parent 24cb2a4 commit b3b646b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reference.module
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ function reference_field_validate($entity_type, $entity, $field, $instance, $lan
}
}

/**
* Implements hook_field_insert().
*/
function reference_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $item) {
if (reference_field_is_empty($item, $field)) {
unset($items[$delta]);
}
}
}

/**
* Implements hook_field_formatter_info() to register the field formatter.
*/
Expand Down

0 comments on commit b3b646b

Please sign in to comment.