I am using an entityform as rendered entity reference field of an eck entity as 'landing page'
I need the form submission to include the title of the landing page. My solution is to add an entityform field and make rules copy paste the landing page title into the field, when submitted.
The Rules trigger is 'After saving a new entityform submission'.
Now I need to somehow fetch the entity ID of the landing page, but how to get the ID from the current entity?
I tried to create a rules component that uses php to get the entity ID of the current entity (landing page) as follows:
{ "rules_get_node_from_current_path" : {
"LABEL" : "Get landingpage from current path",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "php", "rules" ],
"USES VARIABLES" : { "current_landing_page" : {
"label" : "Current landing page",
"type" : "domain",
"parameter" : false
}
},
"DO" : [
{ "variable_add" : {
"USING" : {
"type" : "text",
"value" : {
"select" : "site:current-page:path",
"php" : { "code" : "list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);\r\nprint $id;" }
}
},
"PROVIDE" : { "variable_added" : { "nid_txt" : "NID txt" } }
}
},
{ "data_convert" : {
"USING" : { "type" : "integer", "value" : [ "nid-txt" ] },
"PROVIDE" : { "conversion_result" : { "nid" : "NID" } }
}
},
{ "entity_fetch" : {
"USING" : { "type" : "domain", "id" : [ "nid" ] },
"PROVIDE" : { "entity_fetched" : { "landing_page" : "Landing page" } }
}
},
{ "drupal_message" : { "message" : "Current landing page title: [current-landing-page:title]" } }
],
"PROVIDES VARIABLES" : [ "current_landing_page" ]
}
}
..but that gives me the following errors:
Notice: Undefined variable: entity in eval() (line 1 of /home/cdt/public_html/sites/all/modules/rules/modules/php.eval.inc(146) : eval()'d code).
Notice: Undefined index: entity keys in entity_extract_ids() (line 7874 of /home/cdt/public_html/includes/common.inc).