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.

  • I already answered this question here. Have a look.
    – SaV
    Commented Oct 17, 2012 at 9:10


Your Answer

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

Browse other questions tagged or ask your own question.