Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
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 '13 at 8:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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