Create Content Fields "on the fly"

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
DrupalCuckoo's picture

Hi,

I'm building my user profiles with cck and the content_profile module. To explain my problem/question here's a little example:

The user profile containes fields to collect information about himself and his children (birthday, school and gender for each child). Because the quantity of children differ from family to family I don't know how many content fields are needed to be created in the first place (five children, six children … 20 children?).

Until now, all user information are stored in one content type (information about the user himself and the user's childrens information). I'm thinking about to separate the children's content fields from the user profile information and create a new content type for the children's information. Then a user could click "create a new child" such as creating a new blog entry. So he could enter as many information about his children as he needs I don't need to fear users with unbelievable amount of children ;).

Another way I thought about is to create content fields for 20 children (just to be safe!) so there would be 60 content fields (birthday, school and gender for each of the 20 children). Then I would utilize jQuery to hide all those fields and create an "add button" to unhide those fields (each click on the "add button" shows 3 more fields: birthday, school, gender).

My third option would involve an incredible amount of time to search the whole net for a module that would give me the "add button" on the edit page of a user's profile. Everytime a user clicks on the "add button" three content fields are created "on the fly". No extra content type, no pre-created content fields.

Which way is the best to go? I've really no idea.

Thanks for any help :)

Comments

Multiple choices

smk-ka's picture

Second and third option, no ;)

There are two ways to achieve this kind of data structure:

  1. Use the experimental CCK 3.x branch, enable its Content Multigroup module, and create a grouped field named 'child' where you put all related subfields (birthday, school and gender). Set this multigroup field to 'unlimited'.
  2. The 'classic' way to build such a data structure is to create relationships between two content types using node references (also part of the CCK suite). Namely, you would create a 'parent' and a 'child' content type, and connect both using a node reference field. To make this process more straightforward, you could also use the Node Relationships module to create those 'child' nodes on the fly (while editing the 'parent' node) using a convenient modal popup window. The raw Node Reference module doesn't offer this kind of advanced UI.

-Stefan

Hi Stefan, thanks for your

DrupalCuckoo's picture

Hi Stefan,
thanks for your reply.

Second and third option, no ;)

That's the impression I was getting while I was searching for ;). So, my first idea (creating a separate content type) is the way people usually go when trying to achive such a thing? I'll get used to it ;)

So let's say the content type Parents contains the content fields Firstname and Lastname. The content type Child contains Birthday, School and Gender. Could you tell me how to "connect" these two content types by using "node reference" and "node relationship" so that a user is able to add new children to his profile while he's editing his own profile page (domain.com/user/1/edit)?

Thanks a lot! :)

An answer(:) and a Question(?)

pendashteh's picture

@DrupalCuckoo: You should add a filed named children with multiple values, with the type of Node Reference field.

and here is my situation:

i have got some Cities. at the other side there are some Items. Every month, my editors should make a list of values of Items for each City.

how should I implement it with Drupal and two content-types of City and Item?

Try Flexifield

TheThumbPuppy's picture

Hi DrupalCockoo

Try Flexifield at http://drupal.org/project/flexifield. I am using it successfully for similar scenarios to yours.

Also notice that Flexifield seems to be the viable solution while other solutions are being made stable http://drupal.org/node/773868

You can create a content type "child".

Then create a content type "parent" .

In the content type "parent" add a flexifield field of type "child" and set it to "unlimited" (that way you can add as many children as you like")

I hope these quick notes make sense to you

Good luck! :)

Ivan

thank you ivanpellegrin, I'll

DrupalCuckoo's picture

thank you ivanpellegrin,

I'll give it a try (although it's still alpha and it hasn't been updated for almost a year!)

Best regards,
DrupalCuckoo

I've found another module ->

DrupalCuckoo's picture

I've found another module -> http://groups.drupal.org/node/49558

What do you guys think about this one? Looks very promissing to me (and it's not alpha, it's already beta4). Did anyone tried this module out?

hi, I just wanted to state

DrupalCuckoo's picture

hi,

I just wanted to state that this module didn't work for me at all. The first time you create a new node the default settings is that you get 2 entries (created by the module). You
can add more entries if you wish. But everytime you hit the "save" button it automatically creates a new entry (which will show up in the frontend).

Just try it out and you'll see whats I mean (I'm not sure if I explained it right).

So, I'm still searching for the right solution.

best regards.

subscribe

frank0051's picture

subscribe

subscribe

DystortedSylence's picture

subscribe

Advanced - Nodes that can be referenced (View)

beto_beto's picture

Advanced - Nodes that can be referenced (View)

how can i use it
and why we can use it ??

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week