Cover by Sammy Spets

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Attaching a field collection to a content type

Programmatically creating a field collection can be done in much the same way as we did with fields. Because we have already created the field collection, we can now perform the following steps in order to have these added to recipe nodes at installation time or after an upgrade:

  1. Export the field collection to code inside a feature.
  2. Copy the exported declarations into the recipe module and rename field_ingredients to recipe_ingredients and change the prefixes of the fields within the field collection to ri_.
  3. Tweak the recipe module code to remove the legacy fields from the field admin UI and node edit forms.
  4. Add update code to attach the new field collection to recipe nodes. We will defer copying data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required