3

Is there any Drupal productivity tool that will help me create multiple fields at the same time? I'm taking about about the actual creation of the fields under /admin/structure/types/manage/node_type/fields. I have a hundred of fields to create and it seems tedious to keep hitting the save button every time I create one.

2 Answers 2

1

Just wondering about the use case for hundreds of fields - this seems a bit bizarre. Maybe consider using Field Collections to group similar fields and combine with use multiple values per field on a field collection.

As for a possible solution (although not recommended since a lot of things could go wrong) - if you have many similar fields you could export some "base" fields using features and copy-paste inside the features' files the relevant fields. Clearing cache or feature-revert would create the relevant fields.

2
  • Not hundreds, just a hundred somewhere around 120. But they are spread across two node types. Yes a lot of them have the same field type, creating even just 20 fields at the same time would already ease my work.
    – joejam
    Apr 6, 2015 at 20:52
  • So go with the copy-paste of features. It's a bit technical: You'd have to make sure all the relevant things are copied and names match (in mymodule.features.field.inc and .info files for example)
    – Amir Arbel
    Apr 6, 2015 at 21:06
1

Another path that's different from Moo64c's good suggestion using the Features module, is to use the Drupal API to create the fields programmatically using field_create_field() & field_create_instance(). Here's an example tutorial. You can find many different examples over the web.

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.