I would really appreciate if somebody could help me with this :)

I have a field collection called field_formations. Inside it I have 2 fields:

  • field_technologies - (reference to a taxonomy).
  • field_diploma -(how it's also a field collection which contain 2 other fields:
  • field_name(reference to a taxonomy)
  • field_establishement (text plain) ).

    I've created a form with 3 field forms
  • technology
  • diplome_name
  • establishement

    and into the submit form i would like to submit values of this forms into the node created at first.
    I tried to setValues like this :

but it dosen't work
Can any body have a suggetion??
PS : I'm using drupal 8

1 Answer 1


You need the id of the field collection item (grand one) which you can find inside the node object. Then you load the field collection by that id as an entity. Edit this field collection and save it as an entity. The point is that you have to load the field collectin entity, make changes and save it.

  • Can you explain me more with an exemple?
    – user59552
    Commented Apr 5, 2016 at 16:50
  • I think the same should apply more or less for Drupal 8. First you have a node >> a field_collection meta field that holds the id of the field_collection associated with that node >> once you have loaded this integer, load the field collection entity using entity_load(). From this point work with it as you would do for any other entity using the entity_api like logic under Drupal 7. See this: api.drupal.org/api/drupal/core%21includes%21entity.inc/function/…
    – W.M.
    Commented Apr 5, 2016 at 17:03
  • thnks .... but how about loading the value of the forms in fields related to field collection?
    – user59552
    Commented Apr 6, 2016 at 10:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.