To copy/move fieldset from one content type to another with all included fields in it

Comments

keesee’s picture

+1 support for fieldgroups would be great. Not so sure if it makes to just send all the fields in a field group.... Having check boxes for groups in addition to fields would be best. allows to to select the fields individuality. select them all or just a few. Keeps different user cases open this way... more flexibility.

great idea on this... I love simple contributions that save you time out of the box. well done!

thanks,
J.

joachim’s picture

Status: Active » Fixed

I've added something that lets you clone any or all of the fields of a bundle to any other bundles.

keesee’s picture

The field export is great. I think @PlayfulWolf was suggesting fieldgroups aswell. That what caugh my eye. Moving fields is a huige timesaver, but I still needed to recreate the groups and place fields on those other entities individually.

Thanks again.
--
J.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

petednz’s picture

looks like a v useful module
even being able to copy over the fieldset but still have to drag the fields to the right set would be a time saver
but certainly seeing the fieldsets and fields and being able to select either / both would be awesome

joachim’s picture

Not sure exactly what it is you're asking for, but please file new issues for new things, and bear in mind this is a developer module -- new features will happen when people post patches!

petednz’s picture

Hi Joachim - I didn't feel this was a new issue since it is exactly what was requested in the OP.

When creating Content Types with many fields, we also create Fieldsets that we can group the fields in, using vertical tabs etc.

Being able to copy these to another bundle would make things easier. As it is, your wonderful module lets me effectively clone all (or some) of the fields from one Content Type to another.

But from my testing, there is no way to let me copy over the Fieldsets, so there is still a bunch of work to do to complete the 'cloning'.

I understand this is a developer module and will be happy to take a look at what might be involved, but you may already have a sense that this might be a hard ask given the work you have already contributed.

hope that makes my earlier post clearer.

joachim’s picture

Status: Closed (fixed) » Active

> I didn't feel this was a new issue since it is exactly what was requested in the OP.

Ah fair enough. It looks like I didn't properly read the OP!

I'm not sure how fieldset work. They're a different kind of thing to fields; you'd need to look into the module's API.

joachim’s picture

Title: To copy/move fieldset from one content type to another with all included fields in it » Support copying fieldgroup from one content type to another with all included fields in it
owen barton’s picture

I don't have time for a patch right now, but I just implemented this for another module - should be easy enough to add (inside a module_exists('field_group') check) if someone wants to give it a shot - here is how it looks:

      $source_mode = ...;
      $source_entity_type = ...;
      $source_bundle = ...;
      $dest_mode = ...;
      $dest_entity_type = ...;
      $dest_bundle = ...;
      $groups_to_clone = field_group_read_groups(array('bundle' => $source_bundle, 'entity_type' => $source_entity_type));
      $source_groups = $groups_to_clone[$source_entity_type][$source_bundle][$source_mode];
      if (!empty($source_groups)) {
        foreach ($source_groups as $source_group) {
          // Recreate the identifier and reset the id.
          $source_group->id = NULL;
          $source_group->entity_type = $dest_entity_type;
          $source_group->bundle = $dest_bundle;
          $source_group->mode = $dest_mode;
          $source_group->identifier = $source_group->group_name . '|' . $dest_entity_type . '|' . $dest_bundle . '|' . $dest_mode;
          $source_group->disabled = FALSE;
          unset($source_group->export_type, $source_group->type, $source_group->table);
          // Save and enable it in ctools.
          ctools_include('export');
          ctools_export_crud_save('field_group', $source_group);
          ctools_export_crud_enable('field_group', $source_group->identifier);
        }
      }
user654’s picture

.

user654’s picture

.

cnario’s picture

Issue summary: View changes
rudins’s picture

I started working on changes to get this functioning.
For now on 'Clone fields from this bundle' tool it is possible to create and update fields and fieldgroups. There is checkbox 'Update existing instances'.
Patch attached.