Hi. I'm working with 6.x, in the _plupload_imagefield_import_create_node() function. There is a block of code that looks like this:
// Make it easy for other modules to add data to imported nodes using
// hook_form_alter (see http://drupal.org/node/714550 for details).
foreach (array_keys($options) as $key) {
if (!isset($node->$key)) {
$node->$key = $options[$key];
}
}
// Add any additional cck fields set during import.
$type = content_types($field['type_name']);
if (!empty($type['fields'])) {
foreach ($type['fields'] as $name => $field) {
if ($field['type'] != 'filefield') {
$node->$name = $form_state_values[$name];
}
}
}
The first block allows us to pass an $options array into the function to define additional CCK fields to add. That code is fine. Let's say we passed in an $options array for field_myfield with a few values.
The second block of code effectively overwrites any custom CCK fields. It grabs all defined fields for the node type (which will inclue field_myfield), and then for any fields that are not a filefield it populates the value with whatever is in $form_state_values. Since our custom field does not have a value in $form_state_values, this blows away the value from the $options array that was just set in the first code block.
Comment | File | Size | Author |
---|---|---|---|
#1 | 1484750-1.patch | 1.21 KB | rjbrown99 |
Comments
Comment #1
rjbrown99 CreditAttribution: rjbrown99 commentedPatch attached. I just swapped the order of those code blocks.
Comment #2
muri CreditAttribution: muri commentedComment #3
muri CreditAttribution: muri commentedThis patch is not working in the right way. Let's say we also attached some non-filefields to the node type which we assigned the filefield to it via plupload admin settings. If these non-filefields have defualt values they will be lost during node form submission. So these fields need to be attached to form state values
and such a code below can be added to fix the issue.
A patch will be released to fix this issue.