I have a content type that can contain unlimited instances of embedded field collection field_foo
, each collection containing two fields: field_foo_bar
and field_foo_baz
.
I want to modify the node creation form for this content type to pre-populate field_foo
with values from the same field on an existing node.
By default the node creation form has:
FIELD FOO
FOO BAR [ ]
FOO BAZ [ ]
...and I would like to set, e.g:
FIELD FOO
FOO BAR [Bar value #1]
FOO BAZ [Baz value #1]
FOO BAR [Bar value #2]
FOO BAZ [Baz value #2]
How can I do this? I feel like I'm missing something straightforward.
I have attempted to simply clone the empty field collection in hook_form_alter()
and alter the field_foo_bar
and field_foo_baz
values to suit, but it causes problems adding/removing rows and tweaking multiple deltas, weights, etc. makes it seem like I'm barking up the wrong tree.