-1

I am new to open atrium and Drupal and I am building a new site to manage volunteers. I have about 200 fields to add to my users' profiles (So new fields below password, picture, display name, etc...)

Doing this from the Administration » Configuration » People » Account parameters panel will be a cumbersome process so I want to avoid it and instead use a script to create all my fields. This is the best approach because all those fields are very similar, they are there to store multiple integer values for all days within 5 weeks (Notably catering information : number of meals for morning/noon/evening)

After a few researches, I found this module which seems to do exactly what I want : Bulk Creator

The issue is that I don't really understand how I can specify that the fields I want to add are related to user profile. The only way I can think off is to specify it in the content_type parameter, however I can't find any content type related to users in the configuration.

Any other solution to batch create my hundreds of user fields is welcome. I've thrown an eye to the DB tables in order to do it using SQL instructions, but I quickly understood that it was not a good idea :)

5
  • Are you 100% sure you will have to attach 200 fields to one entity? Drupal for sure will not like it... Loading one user would perform an SQL join over all those fields (each field gets is own table). Since you mention fields are similar, perhaps look into field collections. Add a field collection field to the user allowing 5 (or unlimited) values, and then add all repeating fields into a collection? It is lighter for Drupal and now you'd have to create way less fields. Apr 11, 2017 at 18:25
  • I am sure of nothing. As I specified, I am new to Drupal. Atm I am exploring the possibilities offered by Open Atrium in order to migrate my old PHP site to this new platform. It should be able to handle those 200 fields at user level in order to be a good candidate, and your answer tends to show that it is not the case. I will look into the field collection option then. Thanks
    – Thomas G
    Apr 11, 2017 at 18:29
  • You can add the field collections module to open atrium, no problem there. If you can explain the fields you have to create more, I might be able to help you better. (are they indeed repeating, etc) Apr 11, 2017 at 18:32
  • It's for a music festival. Our workers/volunteers (500 persons) are there for max 5 weeks (some only one week, other 4...). They will register on the new site and for each day they have to specify if they take their meal at the catering, for possibily 3 lunches a day (breakfast, noon ,dinner), and since they might register for other people it should not be a boolean but rather an integer value. Other daily fields are there to reserve a room or just signal their presence. All this is thus repeatable for each day within 5 weeks. You know everything :)
    – Thomas G
    Apr 11, 2017 at 18:39
  • No need to say that admins should be able to extract easily accurate lists from this information entered by users.
    – Thomas G
    Apr 11, 2017 at 18:41

1 Answer 1

2

Rather than creating 200 fields on one entity (this will definitely slow down Drupal), you could group the repeating fields using field collections.

Since you mention there are several fields per day, I'd combine all similar fields into a collection.

So start of with the user and add a field collection field which you name 'weeks' or something and configure it to take 5 values (one for each week).

Now edit the newly created field collection (admin > structure > field collections) and add a new field collection which you name 'days'. This field can contain 7 values.

Again, edit the created field collection and add all fields you need for one day. So one field for the room, one for the amount of breakfasts, etc.

You now have a structure like this:

User 
  - 5 week field collection
    - 7 days field collection
      - room
      - # of breakfasts
      - ...

This is structure you can create by hand it would be about 10 fields.

Reading and printing the data can be easy done with views, but there are quite some tutorials out there already. If you can't figure it out, feel free to ask a new question.

8
  • I see. Sounds like an elegantly structured approach :) I will look into it tonite. I am just a bit worried about this : Drupal 8 Versions Paragraphs is likely to replace field collection for Drupal 8. Field collection is on its way to being deprecated. Open Atrium is running on Drupal 7 but wont for life. So it looks like a risk that my data wont be exploitable anymore after the next big upgrade and that i would have to rebuilt everything differently... nope?
    – Thomas G
    Apr 11, 2017 at 19:08
  • Good point never noticed that. Considering the 170k sites there will likely be some sort of migration path. If you prefer to use paragraphs instead, it works pretty similar to this. The order of actions is only a bit different; you should create the paragraph type first and then add it as a field. Apr 11, 2017 at 19:16
  • I started with field collection. It looks promising ! I only have a major issue atm: I see no way to adapt the label of each occurrence. So I end up with tons of fields but we have no idea for which day it is. Is there a way to setup different labels for each occurrence of weeks and days? In my actual PHP application, those labels are generated dynamically to match the exact date in format ddddd dd/mm, based on the festival start date which is a parameter in our control panel. Ideally I should achieve the same thing here otherwise that won't be practical...
    – Thomas G
    Apr 11, 2017 at 20:53
  • You would not have been able to achieve that with 200 fields either ;) (Writing a longer response) Apr 11, 2017 at 20:56
  • yes I would with some PHP kung fu^^ Not sure how but I would lol. So you see no simple way to do this?
    – Thomas G
    Apr 11, 2017 at 20:57

Your Answer

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

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