content type with multiple input entries

7 replies [Last post]
Last seen: 11 years 1 week ago
Joined: 2011-01-25

Hello, I hope someone can help me. I am trying to build a new content type. One of my questions within the content type is a grid entry type. Basically it asks the individual to list companies they are qualified to sell insurance for. basically each would be a little sub-input form asking the following questions for each:

  1. Name of insurance company
  2. Type of Insurance you are allowed to sell (drop-down)
    Submit company

Then I imagine the information will go to a grid display. And the user could click a button that says "Add Another" and they would be asked the same qustions above, until all of their insurance companies are added to the line.

Keep in mind, this insurance section is in the middle of a much larger form that is gather all sorts of details from the user. e.g. Business name details, address details, etc.

Does anyone know how I can create a sub-section within that will allow multi entries within an bigger form?

I have tried googling words like "grid", "matrix" but haven't found anything. The closest I have found was a multi-step (FAPI) discussion, but I really don't understand how to implement it.

Ultimately all of this information needs to be collected in the database as seperate entries under the same business (e.g. node), so I do not think Webform module will work because it does not save entries as different fields.

Any help is much appreciated.



Chris Shattuck
Last seen: 10 weeks 4 days ago
Joined: 2009-08-16
Hello Josh, What you're

Hello Josh,

What you're looking for is potentially a pretty complex operation. I can't think of a very simple way to go about it, but let me give you a couple of hints that might point you in the right direction.

The easiest solution I can think of is to take a regular text field, enable multiple values on it (which will give it the 'add more' option) and then use hook_form_alter() to replace the single input with multiple values. You would then need to create a validation function to pull the separate values into the one value that lines up with the original input.

The 'right' way to do this is to create a new field type, or at least add a field widget for adding an alternate interface for an existing field type. However, that involves having a pretty good understanding of the Field API, and would be quite a bit more complex.

I hope that helps!


Last seen: 11 years 1 week ago
Joined: 2011-01-25
Chris,Thanks for the update.


Thanks for the update. Your information really helps. I am planning on creating a custom field. But as far I understand, each "question" is a different field type. And I am asking about 3-5 questions for each section which the user will input multiple times (as many instances as they have).

This should be a very interesting project that could take me awhile since I am very new to coding and drupal. Hopefully I can figure it out.

Basically the questions are being asked within a big application form for a House Mortgage. This is just a small subset of questions within the big form. I am using "Field Groups" to group the questions together (related to insurance).

It would look something like this:

Main Application
Blah Blah

Insurance Section (Fieldgroup)
-- For each of your insurance providers please present the following information:
-- Company
-- Coverage Amount
-- Input #3
-- Input #4

-- The four entries would be pulled into a grid format dynamically (users could add/edit/remove rows)

Other sections of application

Submit entire application. (e.g. submit node)

If you have any ideas on how to get the questions within the fieldgroup to dynamically take the input of the user, add them to a grid display and then reask the same questions when the user selects ("add another" button), I would really appreciate it.

Once again, any help is appreciated, thank you,


Last seen: 8 years 34 weeks ago
Joined: 2012-07-14
Field Collection

It seems that the Field Collection module would do exactly what you're looking for.

Practically you would create a field collection, which is basically a bunch of fields that you would configure in more or less the same way as you would within a content type. Then you can treat your field collection as a single field, meaning that you can "add another".

I recently used it to create an Image Gallery within a single node ( much simpler ). Within the field collection, I created an Image field and a Textfield for the caption. When creating a new node, I can then add as many Images with caption as I wish.

Last seen: 11 years 1 week ago
Joined: 2011-01-25
Update: Input Step 9 using AJAX

I rewatched the video related to using AJAX and at the very end it illudes to an example of collecting information about family members and then clicking a button called "add another" and then a new collection line appears.

This is exactly what I want, although I am strugging to figure out how to implement it. I want to use the Content Type build, rather than completing customizing my own form. This is because my form has about 60-90 input locations (its a house mortgage application process) and using Content Type make it very easy to work with fields and display of fields with minimal coding.

So, the question is can I create a feature like the "add another" into a custom field to be used within content type?

Similar to the example in Input Step 9 (using AJAX), mine would also collect input for about 3 fields and then "add another" button pressed and a new line is needed to collect new input for the same 3 fields. All needs to be stored appropriately within the database.

Anyone know any code or anyway to figure this out?

I appreciate anyones' help as I am under the gun at work to try and figure this out.



Last seen: 10 years 19 weeks ago
Joined: 2011-03-13
Wallace, you might take a

Wallace, you might take a look at the recipe module ( as the way ingredients are added sound exactly like how you need your form to work. Ingredients are basically a subform containing multiple fields that get added to a grid within the recipe form. I'm still getting my head around how its done as well but if you test that module out and look at the code, it might help you figure out how to go about your project.

Last seen: 6 years 35 weeks ago
Joined: 2011-03-12

If you use 6.x you can try cck 3.0. It has a multigroup module that will let you group fields together and add another like you ask. Not sure what this looks like for 7.x

Chris Shattuck
Last seen: 10 weeks 4 days ago
Joined: 2009-08-16
Hi Josh, Were apmsooner's and

Hi Josh,

Were apmsooner's and redndahead's feedback enough to get you on the right track?


Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.