I have an integer cck single on/off checkbox field called hide_image. The values are 1's and 0's. The data is properly set in the CSV/TSV and maps properly on the mapping page. Unfortunately, once you are on the node preview section right before importing, all the 1 fields are set to 0. I looked at the code and it should work properly from what I can tell. I even printed $value under "case 'number_integer':" in content.inc and the 1's appear. All 1's are last thereafter.

Comments

Bobuido’s picture

I'm also having problems importing (to cck) integers

I've tried:

Using the label
Using the key

Removing the label from the definition settings and just using the key in the import

Think I'm going to give in now and just do 600+ records by hand

At least there are only two possible values and given the default is the majority of them I should only have say...100 to actually edit :)

If you can't do it the smart way - Do it the hard / long way! :)

robomalo’s picture

I did the import, then went into phpmyadmin and made a table with the right values, matched against some criteria, and did set update MySQL query. It other words, this isn't as good as the module just working properly. I looked at the code and it appears to be correct.... I couldn't figure it out.

joachim’s picture

Title: Single On/Off Integer Checkboxes Does Not Work » CCK fields with checkboxes or radio button widgets don't import
Status: Active » Needs review

I am having the same problem with a text field that has a set of checkboxes as a widget.

I've chased the problem down to optionwidgets.module -- all CCK fields that have radio/checkbox-type widgets are affected, I'm guessing -- updating the title of this issue accordingly.

The node_import module calls node_view.
This invokes hook_node_api on all modules.
CCK's content module calls _content_widget_invoke to invoke all widget hooks.
If the widget for a field is an option set, we get to optionwidgets.module.

The function optionwidgets_widget($op, &$node, $field, &$items) is expecting an $items like this:

Array
(
    [key] => M
)

but it's getting:

Array
(
    [0] => Array
        (
            [value] => M
        )

)

Here is a dirty fix that I've tested on my own case:

Above:

        // Unset the dummy column value.
        unset($node->$dummy_name);

add:

        // some widgets require special handling 
        // or they will clobber data in the preview part of the nodeapi call
        switch($field['widget']['type']) {
          case 'options_buttons':
            $node->$field_name = array(
              'key' => $value,
            );
            break;
          case 'options_onoff':          
            $node->$field_name = array(
              'keys' => $value,
              );
            break;
        
        }

It's not exactly graceful, as I'm clobbering the $node->$field_name without entirely understanding what it does.
But it works for me for both a radio button set and a single on/off checkbox :)

danielb’s picture

Is this a dupe of http://drupal.org/node/273423 ??

I know this was first - but the patch has been reviewed there

joachim’s picture

Yes, that looks the same.
I'd seen that issue but hadn't read the patch properly...

m4manas’s picture

Correct it is the duplicate. The easy way to import large data is

1. convert your field type to text and perform imports. After import convert it back to radio / select etc.
2. You can also apply the patch as mentioned in the http://drupal.org/node/273423 thread. If you have one time need of import then option one will do just fine.

danielb’s picture

Status: Needs review » Closed (duplicate)