This site is archived.
Skip to Content

Content Multigroup and FlexiField: Create Complex Fields by Combining Simple Fields

Your session in a few words: 
Approaches to creating complex fields in Drupal 6 and in Drupal 7
Track: 
Code it, test it, deploy it
Session Type: 
Lecture
Level of expertise: 
Intermediate
Language: 
English

We all love CCK and Views! With lots of amazing field modules out there, you can create almost any content type you need without writing a single line of code, have a reasonably usable form into which to add your content, and create pages that let you slice and dice that content in all sorts of ways. As a result, a big part of site architecture now is planning what content types you need and what fields are needed to represent that content type. Fields have become such an important way of structuring a Drupal website that starting with Drupal 7, the entire Field API is part of core. We've almost removed the need for writing code to build a custom content type. Almost, but not quite! What happens if you need to group fields and then build content that needs multiple instances of the group?

For example, suppose you want to build a content type "Contact". You want this content type to have a field for "Name", and another field for "Phone Numbers". The "Name" field can be set to single-valued, but you want the "Phone Numbers" to have an unlimited number of values, since some contacts might have many phone numbers they can be reached at, and you don't want an arbitrary limit for this. If your Phone Number field can be a simple text field, no problem: enable the text module, create the field, and set it to "unlimited". But what if you want the data entry for each phone number to be 3 separate text fields: area code, number, and extension? Well, you can search drupal.org to see if there's a phone number field module that represents a phone number in this way. Or, you can write such a module yourself. You might be able to find existing modules that handle common data types like phone numbers, but what if you have a similar use-case for a more esoteric combination of fields?

There are two modules in active development that let you create multi-valued field combinations without needing a dedicated module to handle the specific combination. These are the Content Multigroup module that is part of CCK 3.x (a not-yet-ready-for-release version of CCK) and the FlexiField module (still in alpha at the time of this writing). This session will cover:

  • what these modules do
  • how to use them
  • how they work
  • the relative advantages/disadvantages of each one
  • challenges left to overcome for each of them
  • what still needs to be done for this to be a stable and standard part of CCK