0

We have a new project that is going to allow users to add their own nodes of a content type e.g. 'cars'.

There are some existing fields that they need to complete e.g. 'colour' and 'year'. We also need to allow them to add their own custom fields, which only they can use. So one user will add 'mileage' whereas another might want to add 'number of seats'. How would I go about allowing hundreds of users to do this without bloating the content type?

We will be building it in Drupal 7.

Thanks for any help.

1

I was thinking the user would be able to define fields of all of their nodes, not on a one by one basis. in other words, they define 'colour' once in their 'settings' and then add the colours for each car - not the label and the value

I don't know any module that offers this out of the box, so you would need to write your own custom module. You could try to add a new paragraphs or field_collection field to the user's profile and let them define what custom attribute (e.g. "colour") they want to define (at least in D8 there's also the \Drupal\user\UserDataInterface that can be used to store personal user preferences). Then use a hook_form_alter or something similar to adjust the form when adding a new car and display the name of that specific attribute as a label to another paragraphs/field collection field (which then holds the actual data ,e.g. "red").

1

Use Field Collection module.

Install Field Collection module

Create a field collection field to a content type and set to unlimited.

Then create a fields with two text fields - "label" (for 'colour' and 'year') and "value" for that field collection

So when the node add form loads user will have two fields, Label and value with add more button there user can click and add another set of "label" and "value" pair.

  • Have a look at the paragraphs module too, you can achieve the same things. At least for Drupal 8 field collection is likely going to be replaced by paragraphs. – theuni Apr 9 '18 at 15:25
  • Yeah that does look like it will do the job - to some extent. I was thinking the user would be able to define fields of all of their nodes, not on a one by one basis. in other words, they define 'colour' once in their 'settings' and then add the colours for each car - not the label and the value. Gee I ask a lot. – gillarf Apr 10 '18 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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