Turn a tag field id into an instance of the tag model The add-on I'm using to import blogs has this to save tags to an entry:

craft()-&gt;relations-&gt;saveRelations($tagFieldId, $entryRecord['elementId'], $tags);

Where the first arg is the field id for the tag, the second is the entry, and the third is the tags.

I'm getting an error that says $tagFieldId needs to be an instance of the tag model:


  Argument 1 passed to Craft\RelationsService::saveRelations() must be
  an instance of Craft\FieldModel,


Can I turn my little field ID into an instance of this? How do I get a fresh one, if not? Thanks for your help.

Any suggestions on approaches appreciated.

Also - would tag tagmodel but I'm a wee newbie.
You need to get the FieldModel using the $tagFieldId variable, and then pass that model into the function as follows:

$tagFieldRecord = FieldRecord::model()-&gt;findById($tagFieldId);

$tagFieldModel = FieldModel::populateModel($tagFieldRecord);

craft()-&gt;relations-&gt;saveRelations($tagFieldModel, $entryRecord['elementId'], $tags);