2

I have a node that will have one field that will be updated often by adding a field with a time and quantity of an item. I would like to output the data as a table.

Some fields the node will have are:

Title
Description
Type
Year

Then it will have data that is updated attached to it:

Monday | 4
Tuesday | 7
Friday | 3
Sunday | 9
Monday | 3
Friday | 7
.
. 
.

I need a field to contain both the data/time and the quantity. Do make a new entity to contain this information and have a mutli value entity reference field? Do I create a field collection? Do I instead make a two value field with the field API? What is the simplest way to store this data? The field will be updated programmatically.

1 Answer 1

1

These are just my opinion...

  • A custom entity would probably be overkill, unless you plan to extend the functionality at some point. If your end game is just to store those key/values pairs, the extra code and DB complexity doesn't feel worth it.
  • To extend on that, Field Collection already implements that entity for you, plus all of the entity/field/views niceness. Add the Field Collection Table module as a table formatter, and you'll be probably be ready to go in about 10 minutes.
  • A custom field (and formatter for the table) would be reasonably straight forward to implement, but is tricky to extend if you decide, for example, you need another data column. It does have less DB overhead than the Field Collection method (as there isn't another entity involved), though, in case performance is a major issue.

If you're looking for simple, I'd say Field Collection is the way to go.

Your Answer

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

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