2

i want to copy a field from one entity to another while processing a rule. my current code looks like this:

<?php
    $entity_created->field_ort = $entity_fetched->field_ort;
?>

but instead i get an error message:

Notice: Trying to get property of non-object in eval() (Zeile 3 von /www/www/sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code).

so i found this site http://drupal.org/node/1000200 which tells me that i need to do this more like this:

<?php
    $entity_created->field_ort['und'][0]['value'] = $entity_fetched->field_ort['und'][0]['value'];
?>

but what about lists and other fields? is there a more generic approach? i need to copy about 5 or more fields.

1 Answer 1

0

That issue and the following code seems to have no bearing on the opening problem. Trying to get property of non-object, it literally means that $entity_fetched is not an object. Dump it into a file to see what it is.

1
  • yes, you are right... $entity_fetched is a List of Entities... right below it i used $entity_fetched[0]->field... and totaly oversaw that
    – reox
    Jan 16, 2013 at 8:35

Your Answer

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

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