How do you add tags to tag field when saving an entry? I'm working on a custom import plugin which needs to import a load of content to fields including categories and tags. Categories is working fine using a comma separated list of category ids:

        $entry = new EntryModel();
        $entry-&gt;authorId  = $eventObject-&gt;author;
        $entry-&gt;enabled   = true;
        $entry-&gt;postDate   = $eventObject-&gt;postDate;
        $entry-&gt;getContent()-&gt;title = $eventObject-&gt;title;
        $entry-&gt;getContent()-&gt;setAttributes(array(
            'slug' =&gt; $eventObject-&gt;slug,
            'locationText' =&gt; $eventObject-&gt;locationText,
            'date' =&gt; $eventObject-&gt;eventDate,
            'overview' =&gt; $eventObject-&gt;overview,
            'eventWebsite' =&gt; $eventObject-&gt;eventWebsite,
            'eventCategories' =&gt; $eventObject-&gt;categories,
            'location' =&gt; $eventObject-&gt;location,
            'eventTags' =&gt; 1453,
        ));


I just can't get tags importing at all, also need to create new tags where a tag doesn't already exist! Testing with the id 1453which is an existing tag id.
Like other relational fields, Tags fields’ values need to be set to an array of the tags’ IDs.

It’s not possible to create tags during entry creation; you would just need to create it first using TagsService::saveTag().

$tag = new TagModel();
$tag-&gt;groupId = 1;
$tag-&gt;getContent()-&gt;title = 'My Tag';

$success = craft()-&gt;tags-&gt;saveTag($tag);

if ($success)
{
    $tagData = array($tag-&gt;id);
}
else
{
    $tagData = null;
}

// ...

$entry-&gt;setContentFromPost(array(
    // ...
    'myTagsField' =&gt; $tagData,
));

// ...


(Note that I’m setting the field value using setContentFromPost() instead of directly on the ContentModel. This is the recommended way to set your custom field values, although for relational fields it doesn’t really matter either way.)