content type with multiple input entries
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:
- Name of insurance company
- 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. http://public-action.org/content/drupal-7-form-api-drupal-7-multi-step-f...
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.
Thanks,
Josh
Chris,
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,
Josh
It seems that the Field Collection module would do exactly what you're looking for.
http://drupal.org/project/field_collection
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.
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.
Thanks,
Josh
Wallace, you might take a look at the recipe module (http://drupal.org/project/recipe) 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.
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
Hi Josh,
Were apmsooner's and redndahead's feedback enough to get you on the right track?
Cheers!
Chris
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!
Cheers,
Chris