I want to copy the values of the field collections from entityform to node form, using the Rules module.

I tried to loop my field collection, then set value of the field collection from entityform to entitycreated, but this didn't work. I only get blank fields but the number of field collections are the same.

For example I have 5 field collection items per field collection and 5 field collections from entityform, after executing the rule I also have 5 empty field collections on the entitycreated.

Here's a sample of the rule:

{ "rules_after_submitting_entityform_custom_package" : {
"LABEL" : "After submitting entityform Custom package",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "entityform" ],
"ON" : { "entityform_update" : [] },
"IF" : [
  { "data_is" : { "data" : [ "entityform:type" ], "value" : "custom_package_entity_form" } }
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "sample",
        "param_title" : "Your Event",
        "param_author" : [ "site:current-user" ]
      "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }

  { "LOOP" : {
      "USING" : { "list" : [ "entityform:field-option-criteria" ] },
      "ITEM" : { "list_entity_form_option_criteria" : "Current list item" },
      "DO" : [
        { "data_set" : {
            "data" : [ "entity-created:field-option-criteria" ],
            "value" : [ "entityform:field-option-criteria" ]
  { "data_set" : {
      "data" : [ "entity-created:field-entityform-referenced" ],
      "value" : [ "entityform" ]
  { "entity_save" : { "data" : [ "entity-created" ] } },
  { "redirect" : { "url" : "[entity-created:url]", "destination" : "1" } }
] }}

Any idea, how to set this the right way?

Also, after creating this rule, I get this error when trying to delete the node created:

Fatal error: Call to a member function delete() on a non-object in /sites/all/modules/field_collection/field_collection.module on line 830

I also tried using the Entity reference autofill module but it's not auto-filling the fields if I try it with Rules.

Any suggestions?


1 Answer 1


I see 2 errors in your rule, which is about processing a list of field collection items. Each of these errors is further explained below (though I'm not sure if they are the only errors).

Error 1: Rules Condition 'Entity has field' is missing

You should add a Rules Condition "Entity has field" (prior to being able to use it anywhere later on in your rule), which refers to your field collection field. Since your rule doesn't have such condition yet, it may also explain why you got those blank values so far.

For way more details about this, refer to "How to iterate over all field collection items in an eMail body using Rules?" (which also includes a rule in export format you may want to experiment with, if you only adapt some machine names of the used fields).

Error 2: 'Set a data value' needs to be replaced by 'Add an item to a list'

The Rules Action Set a data value that your Rule uses, can only set 1 value, while you're trying to update something that is a list.

So try to replace that action (ie the first data_set within the loop) with an action "Add an item to a list". When doing so, you probably also want to set "ENFORCE UNIQUENESS" to true, so that you "only add the item to the list if it is not yet contained". Even though for your case it may not make a difference, IMO that is a kind of safety-belt when using this action.

For way more details about this, refer to "How to set multiple values to an unlimited Term Refence field with Rules". While reviewing this, also pay attention to the "Fetch entity by ID" (within the Rules loop): I'm about sure (99%), you'll also need to add a similar "Fetch entity by ID" (but from the variable names you used in your rule it's hard to tell).

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.