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'));


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

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

Strange... So this works:


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

What the..


michaellander’s picture

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):


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

    ->arguments(array('source_type' => 'tid'))

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).