Example with "normal" entity reference.

$node = node_load($nid);
$node->field_reference = array(
  $node->language => array(0 => array(
    'target_id' => $other_nid,

Now I want to do the same, but on a File entity field instead. Examining an attached file with devel, the field looks mostly like a plain

$file = file_load($fid);

object, but there's some more data on it, so I'm guessing I will hit problems down the road if I just stick the $file on to the ref, instead of figuring out the proper API call.

1 Answer 1


The file entity module wraps around the core file field, which defines only three field columns that you need to worry about providing:

  • fid (file id)
  • display (boolean indicating if the file is displayed or not)
  • description (self-explanatory)

You can safely ignore any other values that you find on the field as they'll be discarded anyway when it comes to committing the field data.

If I remember rightly it's the core file module that adds the extra data to the field, which is essentially the file object converted to an array. If you're seeing any other 'foreign' values in there they're probably coming from the file_entity_field_load() function.


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.