Multiple fieldgroups with CCK

If you are using Drupal+CCK intensively you will sooner or later run into limititations. One of these is the unability to create multiple fieldset groups. This is a very common problem when you need a way for users to insert an unknown amount of items and each items uses the same combination of fields.

For example: you've got  a profile content-type where a user can provide their education from a pre-defined list (select dropdown) but you also need to provide a year with each chosen education. And you want the user to able to provide anywhere from one to an unlimeted number of these sets.

Using CCK 2.x you will be limited because it isn't possible to duplicate an entire fieldset. It is possible to duplicate single fields by setting the number of values to a higher number but it isn't possible to do this with an entire fieldgroup, like in the screenshot below.

Example created with CCK 3.x Multigroups

Yes there are solutions! And as usual with Drupal, there are several options.

The last option may be unattractive if you're not a programmer or don't want to spend much time on coding.

Flexifield allow for the desired behaviour but it is a bit of a hackish way. It also involves an elaborate process creating separate content-types for each set of fields you want to re-use. It has Views integration but it still feels a bit messy. It looks like CCK 3.x implements this better - see this comparison for some technical details about the database structure.

However, CCK 3.x is still in development and therefore not stable. It was initially developed under CCK 2.x but was officially introduced in CCK 3 . You can still find the patches and process for this module in this issue queue (longest isse queue I've seen so far!). But is definitely not recommended trying to get this to work under CCK 2. If you get it to work you will have a CCK version which you won't be able to upgrade.

Still, it seems the 3.x-dev is being reported to be used without any 'big problems'. There are some issues with still need attention (involving more complex structures like nested fieldgroups) but if you keep a a good eye on the issue queue, it might be the most durable solution.

update : one caveat when using CCK is you won't be able to store multiple values within a field in a multigroup. So for example: you can use content taxonomy in a multigroup but you won't be able to store more then one term for each item. See also this thread.

If you're not sure and happen to be in Paris during the next Drupalcon, you might want to check out the proposed sessions about this topic, a lecture from the author of Flexifield.

Drupal 7
Okay, so what about Drupal 7? We all know fields got in core recently for D7, but what about this feature? Fields in core means a big part of CCK has moved to core. But there will still be a contributed part which might have additional functionality. Back at the Drupal fields-core group, you can read more about this. and apparantly, multigroup has a somewhat lower priority to be pushed in core.

The Drupal 7 Media Library and Design Patterns

Read More »


This is the company blog of
Drupal specialist

We are located in Breda (Netherlands) and build websites using Drupal. More about us.

Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.

Creative Commons License

Recent Comments