In the readme file, it says "Header case is ignored." But I had a header in my CSV file called "MaidenName", so I was trying to access it using
$user_data['MaidenName'];
and it was not working. What is working is this:
$user_data['maidenname'];
I don't think the fieldnames need to be "normalized". Ok, for email, password, and username, it makes sense, because they are special fields that the module is looking for. But for custom fields, like my MaidenName field, I think it would be more intuitive to use them as-is from the CSV file. "MaidenName" is already the "normal" way I am spelling it, not "maidenname". So normalizing it only makes it abnormal. ;-)
I have a fix. I modified the function that does the normalizing, in uif.admin.inc:
function uif_normalize_header($header) {
$normal_header = array();
foreach ($header as $column) {
$lower = strtolower($column);
if (in_array($lower, array('email', 'username', 'password'))) {
$normal_header[] = $lower;
}
else {
$normal_header[] = $column;
}
}
return $normal_header;
}
... and now the following line in my importer works the way I expect it to:
$profile2->field_maidenname[LANGUAGE_NONE][0]['value'] = $user_data['MaidenName'];
Comments
Comment #1
dwightaspinwall commentedMaking the end user get the case right in their spreadsheets is a user trap. I'd rather burden the programmer with the need to write lower-case column names. But you're right, this should be documented, and I'll add it.
Comment #1.0
dwightaspinwall commentedAdd a set of
tags, for clarity.