2

We need to create a content type with large number of fields(50+). Adding fields one by one via UI is one option but it seems unnecessary that so many tables get created when adding fields via UI.

Other option that I tried was Matrix field module which allows inclusion of multiple fields with widget options for select, checkbox, text etc. However it does have few issues with display.

The other alternative is the TableField module. But then it only provides text options.

Are there any other modules that allow creation of multiple fields without the overhead of creating multiple tables at the same time.

Note: A webform cannot be used in this case due to design considerations.

8
  • Did you try the Field collection module? Jul 3, 2014 at 7:21
  • Yes. I have. But it does not resolve the problem of multiple fields creating multiple tables. All of these are different fields - different names and values.
    – Amit Sedai
    Jul 3, 2014 at 7:48
  • 1
    You say it seems unnecessary that so many tables get created when adding fields via UI. Are you talking about database tables here?
    – Andy
    Jul 3, 2014 at 8:34
  • @Andy: Yes. For each field database tables are created,.
    – Amit Sedai
    Jul 3, 2014 at 9:03
  • It doesn't matter whether you use the UI to make the fields or not, that's how fields work with D7 (at least using the default SQL storage engine). What specific problem are you having with the large number of tables?
    – Andy
    Jul 3, 2014 at 9:11

2 Answers 2

1

There are two ways you can accomplish this:

  1. Write a custom field, with the 50 necessary fields compounded into the field's columns (this will create 50 columns in the field data and revision tables, but obviously you've got to store your data somewhere). There's an excellent example of writing a custom field in the Examples module.
  2. Write a custom entity. This is probably more work, but using this method you can make your 50 fields entity properties (rather than fields in the Drupal sense), and the data will all be stored in the base table for the entity. Again, that's a large-ish number of cols for a table, but your data needs to live somewhere.

Both methods give you the flexibility to create the input forms yourself, so either will let you achieve whatever UI you think is most appropriate for inputting that amount of data in one go.

Note that using the standard field API is considered best practice, which is probably why you're struggling to find modules that do it differently.

2
  • I was looking for a module available that supports adding multiple fields without the overhead of creating tables for each. Yes, custom solution would definitely help but I guess that may be an overkill if performance is not in question. Thanks.
    – Amit Sedai
    Jul 3, 2014 at 9:31
  • Yep I understand what you're asking - I'm saying you're very unlikely to find such a module, as the constraints you're placing on their functionality (even though they're doing things correctly) will alienate pretty much all of them. From there a custom solution is the only option really, hence the 2 possibilities above. But yeah, if performance is not an issue just use the built-in stuff, it'll be much quicker from a development point of view
    – Clive
    Jul 3, 2014 at 9:35
0

One of the ways to resolve can be via Field Collection as suggested by @Krishna Mohan for fields requiring similar widget for data storage.

Ex: This can be used if multiple fields are of let's say Yes/No selection type. A field collection allowing multi-value can be created with 2 fields. The first field would provide a list allowing for selecting the parameter(which is the name of the fields of similar type in the list) and the other field would provide an option for Yes/No.

Fields of various categories can be clubbed into multiple field collections.

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.