Support CCK Option Widgets
rezboom - February 26, 2009 - 13:56
| Project: | Node import |
| Version: | 6.x-1.0-rc4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
First things first: Thank you very much for updating node_import to rc4 and including CCK support!!
I am trying to import into a multiple row textfield that is indexed like this:
1|Value one
2|Value two
3|Value three
4|Value four
5|Value five
6|Value six
7|Value seven
In the CSV I have the multiple values like this:
2||3||6
meaning that Value two, Value three and Value six should be imported.
However, instead of the correct numbers (2, 3 and 6) , the number 1 is saved three times.
I did try to use other value separators, but that did not help.
Please also see the screenshot.
Thank you!!
| Attachment | Size |
|---|---|
| n_i_issue.gif | 10.9 KB |

#1
Could you use "Content copy" to export the definition of the content type you are trying to import and attach it here?
Could you attach a sample CSV file (5 rows or so)?
This will make it easier for me to test it and make sure it works.
I'll fix this asap.
BTW you'll be able to use "Value two||Value three||Value six" as well (once this is fixed).
#2
Thank you for your swift response!
The export of the content type I am trying to import data into is attached as text file, because it is probably too long to post here.
I have attached a sample csv as well.
Thanks again for your efforts!
#3
Could you copy optionswidgets.inc from CVS into
sites/all/modules/node_import/supported/cckand test it?Option widgets (checkboxes and radio boxes) apparently need some extra work.
BTW: quite a content type... I have the feeling that the wizard is not that easy (wrong sorting and grouping) if there are many fields... need to look into that later.
#4
#5
OK, I copied optionwidgets.inc into the sites/all/modules/node_import/supported/cck - the result is promising, but the import does not yet work:
To test, I used the attached sample CSV file - note this is a different one from the above posted, with only 1 row.
At step 7 of the import wizard I now get the error "An illegal choice has been detected. Please contact the site administrator."
Completing the wizard is possible, but the import fails.
The output of the record at step 7 shows however, that the correct values are read into the corresponding arrays. Please see the attached record_output_optionwidgets.txt
So, (at least how I see it) it's almost working, but not quite.
BTW: Otherwise the import works very well, despite the size of the content type. :-)
UPDATE:
Looking into the "Recent log entries" revealed this: "Illegal choice Degree name Dr MSC etc in Name of degree/certificate element."
"Degree name Dr MSC etc" is the value to be imported.
I now tried not mapping the the "name of degree" field - and the import WORKS.
#6
Could you look in your log (admin/reports/dblog or similar) what the exact error is? It will tell you on which form element the illegal choice was detected.
#7
Could it be:
[field_course_teach_facility_oth] => Array
(
[0] => Array
(
[value] => 5||6||7
)
)
?
#8
Looking into the "Recent log entries" revealed this: "Illegal choice Degree name Dr MSC etc in Name of degree/certificate element."
"Degree name Dr MSC etc" is the value to be imported.
I now tried not mapping field_course_degree - and the import WORKS.
Sorry for confusing you with the "field_course_teach_facility_oth" - it is a normal text field and the CSV should not contain 5||6||7 there, but "normal" text - but this DID work.
Thank you very much for replying so fast !!
#9
When I look at your "Name of degree/certificate" content field definition, it does not include "Allowed values" (it is empty) - I even get the warning "You need to specify the 'allowed values' for this field." if I go to edit the field.
What is happening is that the FormAPI expects a value (because it is a checkboxes element), but there are no possible options specified. If you create a single node with node/add/course the "Name of degreee/certificate" only contains "N/A", so this is more a wrong configuration of the field then a problem with node_import. Although a nicer error message would probably be advisable (eg seeing that the allowed value list of the checkboxes is empty).
So the optionwidgets.inc needs some more cleaning up.
The import of field_course_teach_facility_oth obviously did work because "5||6||7" *is* text :-) If the field is not configured to contain multiple values, then node_import will not interpret the || as a separator for multiple values.
#10
Thank you for explaining - I already suspected that the problem was due to a faulty content type and not due to node_import.
I will fix this now and then lets import some data :-))
Really GREAT WORK by you!
#11
For the sake of providing a happy ending to this issue:
The import now worked flawlessly!
Thanks again Jacques!!
#12
Thanks :-)
For sake of completeness: my firs name is Robrecht, not Jacques. A common mistake :-)
#13
hello, im having the same problem but still cant get this checkbox cck to import. its seems like you guys have it working so i must be close.
ive been most of a full day trying different combinations and decided to start over with a new simple content type just to get this to work
D6.10 - CCK 6.x-2.2 - Node Import 6.x-1.0-rc4
and ive also added "optionswidgets.inc from CVS"
my CSV file is
title;body;format
Title text;Body text;123||456
Some other title;Body text;789
my CCK values for the checkbox are
1|123
2|456
3|789
attached is the content type. i just added one integer field Checkbox with Number of values: unlimited. Im just trying to keep as simple as possible.
When i get to step 7 of 8 i dont get error message, i see the correct amount of values but not the correct values. it only displays the value "123" which is key value 1.
any ideas greatly appreciated.
#14
I am having the exact same problem as #13.
#15
Using the latest -dev version did the trick for me...
I needed to import a bunch of data that involved multi-select checkboxes and select lists and using the latest version of -dev made everything play nice.
-mike
#16
It doesn't work for me neither, I've a checkbox with
No
Yes|Label
And I have a CCK warning and an error :
"warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in www/drupal/sites/all/modules/cck/modules/text/text.module on line 156.
Label : illegal value"
No problem inserting "No" or "" value, which result on "No" value in base. But impossible to enter a "Yes" value. I've tried with rc4 and dev versions, and with optionwidget.inc or not.
Did someone succeed on such a case or must I investigate by myself?
Regards,
cfab
[EDIT] It works now, but I had to modify optionwidgets.inc to replace:
if ($fieldinfo['cck:fieldinfo']['widget']['type'] == 'optionwidgets_buttons') {by
$option_type = array('optionwidgets_select', 'optionwidgets_onoff', 'optionwidgets_buttons');if (in_array($fieldinfo['cck:fieldinfo']['widget']['type'],$option_type)) {
Now, it works and "Yes" values are those where I don't put anything.
#17
cfab's fix above worked perfectly for me.
Here's that change, as a patch file.
#18
cfab's fix in #16 didn't work for me. While I'm not getting the
* warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in [path]/sites/all/modules/cck/modules/text/text.module on line 156.
* [field name]: illegal value.
error, all the imported nodes have my cck text/checkbox checked, regardless of what the actual value in my .csv was set to.
Any thoughts?