2

I have a content type with field collection field (unlimited cardinality). Each collection has image field (required) and long text field.

How can I prepopulate node form with multiple collections? I need node creation form to have lets say 3 collection widgets (+1 blank) with already uploaded images.

How can I generate field collection widgets? I tried to manipulate with $form_state['values'] and $form_state['field'] in hook_field_attach_form - but have no effect.

Module code at Github

enter image description here

enter image description here

enter image description here

  • What is the field type? A screen shot of the manage fields might help too. – Brady Dec 14 '14 at 12:01
  • Ok screenshots explains why I was puzzled. I had never heard of a field_collection_field. This is provided by a third party module Field Collection. I personally have never used this so I cannot provide an answer. – Brady Dec 14 '14 at 13:22
  • Can you give us more details on what you tried? Have you tried hook_form_FORM_ID_alter already? If you can't access the field collection, maybe you need to use an #after_build callback function to wait for the field collection array to be available for edit. – thedotwriter Dec 14 '14 at 16:06
  • What have you tried? There are several pages that explain how to do this. Including this. A Field Collection object is an entity so most that I have seen should work. If not post what you have tried here and we will try to figure it out. – sareed Dec 17 '14 at 14:55
  • I've tried both hook_form_alter and a #preprocess callback - can't get either of them to work. form.inc fails out on an unrelated element each time. – aaronbauman Feb 17 '15 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.