I'm trying to use the migrate module to import data from a mysql table to Drupal 7. I've created a content type with a field type of boolean and used "single on/off checkbox" as the widget. So in the migration destinations the field is (list_boolean).

The data in the database is integer (0/1).

I set the field mapping: $this->addFieldMapping('field_my_event', 'my_event');

However, none of the 1's get stored as 1 in the field_my_event table when migrated.

I tried also forcing the value to a boolean value of TRUE/FALSE in the prepareRow hook, but that didn't make a difference.

versions I'm working with: Drupal 7.33 and Migrate 7.x-2.6-rc1

Can someone steer me in the right direction?


See this comment on this issue: https://www.drupal.org/node/1729996#comment-9511751

"I found a way to import, you must set the "on" and "off" values.

I went to my field in my content type and set the "on" value to 1 and the "off" value to 0.

In the migration mapping I made a callback function for this field and convert my true value to 1 and the false value to 0, you could do this instead creating a new feature.

This way worked perfectly here.

I don't know if it is a really necessary feature."

  • It's better to copy or resume the linked content because it may be unavailable eventually. – sanzante Jan 14 '15 at 19:58
  • It is not a reason at all to negative rate my comment. – Leandro Perini Jan 14 '15 at 20:03
  • I didn't. May be someone thought that you should add the linekd content and instead of explain the situation he downvoted you. I think you are right, your answer seems ok and not copying the linked content is not a reason to downvote (even more for new users). Keep on. – sanzante Jan 14 '15 at 20:09

Your Answer

