Skip to main content
2 of 2
Major grammar rewrite.
Letharion
  • 27.5k
  • 11
  • 83
  • 141

How to pre populate a node add form with multiple field collection items?

How to pre populate a field collection field with multiple values?

I have a node type with a field collection field which has four fields and cardinality is set to unlimited.

In my custom module I implement hook_form_alter and assign default values to the collection inside a loop, but it displays only one field collection. I tried to set the cardinality of the field collection field to the number of items I want, but failed as I can't find a way to set the cardinality programmatically.

rongok
  • 163
  • 2
  • 11