You are here

function _hashtags_field_attach_terms in Hashtags 8

Helper function that attach a number of terms to the taxonomy terms hashtags field

Parameters

$field:

$tids:

string $vid:

1 call to _hashtags_field_attach_terms()
hashtags_entity_presave in ./hashtags.module
Implements hook_entity_presave().

File

./hashtags.module, line 248

Code

function _hashtags_field_attach_terms($field, $tids, $vid = 'hashtags') {

  // create term and attach to the field
  $hashtags = array();
  foreach ($tids as $tid) {
    $hashtags[] = array(
      'target_id' => $tid,
    );
  }
  $field
    ->setValue($hashtags);
}