We will probably need something like this:
/**
* Implements hook_replicate_field_FIELD_TYPE().
*/
function multifield_replicate_field_multifield($entity, $entity_type, $field_name) {
foreach ($entity->$field_name as $language => &$items) {
foreach ($items as $delta => &$item) {
unset($item['id']);
}
}
}
/**
* Implements hook_node_clone_alter().
*/
function multifield_clone_node_alter(&$node, $context) {
$multifields = multifield_get_fields();
$instances = array_intersect_key(field_info_instances('node', $node->type), $multifields);
foreach (array_keys($instances) as $field_name) {
$machine_name = $multifields[$field_name];
if (!empty($entity->{$field_name})) {
foreach ($entity->{$field_name} as $langcode => &$items) {
foreach ($items as $delta => &$items) {
unset($item['id']);
}
}
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2737769-fix-cloning.patch | 8.78 KB | dave reid |
| #15 | 2737769-fix-cloning.patch | 8.75 KB | dave reid |
| #12 | 2737769-cloning-failure.patch | 6.97 KB | dave reid |
| #9 | 2737769-cloning-failure.patch | 6.51 KB | dave reid |
| #8 | 2737769-fix-cloning.patch | 3.96 KB | dave reid |
Comments
Comment #2
dave reidComment #3
dave reidComment #4
dave reidMaybe it would be better to add this to hook_entity_presave(), that if the entity is new, it should not contain any ID values for the fields.
Comment #5
dave reidPatch should show failure when attempting to do a basic clone.
Comment #8
dave reidShould have all the tests fixed now.
Comment #9
dave reidTests only for basic cloning, node clone, and replicate modules.
Comment #12
dave reidTry that again.
Comment #15
dave reidHoory, expected failures in all the new tests. Combined patch with all new tests.
Comment #18
dave reidFixed the replicate calls to use the right way.
Comment #20
dave reidCommitted #18 to 7.x-1.x.
Comment #22
dave reid