When CCK forms are duplicated, the fieldgroup is not duplicated. I'm also receiving the following multiple warnings:
warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/mallee/public_html/sites/default/modules/cck/content_admin.inc on line 410.

The function area for line 410:

  // The table was created in the form
  // iterate through it and render form elements when placeholders are encountered
  // then run the rows array through theme_table().
  foreach ($form['#table'] as $weight => $frow) {
    foreach ($frow as $delta => $item) {
      foreach ($item as $fname => $field) {
        $row = array();
        $class = 'content-field-overview-enabled';
        if (in_array($fname, $disabled)) {
          $class = 'content-field-overview-disabled';
        }

Line 410 is the if(in_array($fname...etc.

The errors show in watchdog, but don't appear in database cache.

Sorry to be such a pest! Seems I'm prone to problems.

Comments

marcp’s picture

Status: Active » Needs review
StatusFileSize
new5.28 KB

Attached is a patch that fixes the problem of fieldgroups not being duplicated. I put a module_invoke_all('content_duplicate', ....) call in _content_admin_type_edit_submit() in content_admin.inc. The real work gets done in fieldgroup.module's new hook_content_duplicate.

A little bit of refactoring was done to keep from duplicating SQL that was already in place.

yched’s picture

I'm sorry but I don't get what's the issue in the first place and what the patch is supposed to address - can you provide a detailed description of the problem ?

marcp’s picture

Title: Field groups not duplicated » Field groups not duplicate

Here is the problem that is addressed by this patch:

In CCK, create a new content type (admin/node/types/add) and call it abc.
Add two fields (call them f1 and f2) to the new content type (admin/node/types/content_abc/add_field).
Add two groups to the new content type -- call them group1 and group2 (admin/node/types/content_abc/add_group).
Move f1 into group1 and f2 into group2 from the manage fields tab (admin/node/types/content_abc/fields).
Now, from admin/node/types, find the new content type and click duplicate (admin/node/types/content_abc/duplicate)

You should notice that the fieldgroup data doesn't get copied over. All the fields are there, but the fieldgroups are missing. This is actually a big pain when you've got a lot of fields in a type that are all assigned to groups.

Let me know if this describes it well enough. It would be great to get this patch in there.

marcp’s picture

Title: Field groups not duplicate » Field groups not duplicated

Oops, I changed the subject by accident on the last comment.

One other piece of information is that you need to activate the fieldgroup module, but I assumed that people would know that since this is filed against the fieldgroup module...

fago’s picture

StatusFileSize
new1.4 KB

hm, I don't its a good idea to introduce a new hook for just one module. Here is another simple patch, which works fine for me.

yched’s picture

Yes, +1 for not adding a hook.
But I think the code could go in a fieldgroup_duplicate function in fieldgroup.module, called inside the if (module_exist('fieldgroup')) {} block in content_admin (this keeps code dealing with fieldgroups tables contained in fieldgroup module)

fago’s picture

StatusFileSize
new1.95 KB

yep, that's right. here is an updated patch.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Looks RTBC to me

fago’s picture

Status: Reviewed & tested by the community » Fixed

-> committed to the 4.7 branch.

marcp’s picture

Thank you for getting this in 4.7 -- it's much appreciated. Does anything need to be done to get it into 5.x?

yched’s picture

No, the 'duplicate' functionnality does not exist per se in 5 branch. It is handled by content type import / export facilities, which should handle fieldgroups OK.
But thanks for the proposition :-)

Anonymous’s picture

Status: Fixed » Closed (fixed)