0

Let's say, I have a text field which I use it as a phone number field. I set the number of values to unlimited, so people can enter more than one number.

However, I want to use another text field for the definition of that number. Such as:

Name    Number
====    ======
Home    123456
OFfice  234567
Mobile  456789

How can I combine these two fields and require the Name field to be filled when each time a number field is created?

2 Answers 2

2

the easiest way is field_collection:

Provides a field-collection field, to which any number of fields can be attached.

A field collection is internally represented as an entity, which is embedded in the host entity. Thus, if desired field collections may be viewed and edited separately too.

You can make a compound field in code as this Phase2 Blog Post describes .... maybe there's a module for a compound field, but its usually not worth the effort.

2

You can also do this using the Double Field module:

Double field is a small module written to provide extensions to Drupal's core Fields. By this module you can divide your fields into two seporate parts.

For the moment it includes the following sub-widget types:

  • Textfield
  • Select list
  • Single checkbox
  • Textarea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.