Hello,

I'am converting data from an old cms to drupal 7 using Migrate module.
My drupal content type, which I'm creating nodes from, has an annoying "Term reference" field using a "Check boxes/radio buttons" widget.

In my migration class I have tried to hardcode the field value to a "tid" on the checkbox list, and also the machine name eg:

$this->addFieldMapping('field_category', 21)
     ->arguments(array('source_type' => 'tid'));

And

$this->addFieldMapping('field_category', 'Penguins');

But nothing seems to work, no checkbox is highligted on the migrated nodes ;(

EDIT:
Strange... So this works:

    $this->addFieldMapping('field_category')
                 ->defaultValue('Penguins');

And this don't
    $this->addFieldMapping('field_category', 'Penguins')

What the..

Comments

I know this is a month old, but in case someone else has troubles with this..

The issue with your first 2 examples is that you are putting the actual value in place of the source value. The source value is where you should have the name of the property in the row object.

So as you have(which works):

$this->addFieldMapping('field_category')
    ->defaultValue('Penguins');

Alternatively, if you wanted to use the tid, you could use:

$this->addFieldMapping('field_category')
    ->arguments(array('source_type' => 'tid'))
    ->defaultValue(21);

In which case, you are saying that the type of default value is 'tid' instead of the term name(which is what the source_type is by default).