I'm trying to name node after file name of enclosed file. It doesn't work, expect for "fid", which does.
return $entity->field_image['und'][0]['fid']; // This works
return $entity->field_image['und'][0]['filename']; // This doesn't work
If I try to use "filename" property, I get:
Notice: Undefined index: filename in eval() (line 1 of /home/s670d6c974eb0654/www/sites/default/modules/auto_entitylabel/auto_entitylabel.module(358) : eval()'d code).
The problem must be in AEL, because it works with Display Suite Code Field, which uses the same mechanism.
Comments
Comment #1
bforchhammer commentedNot really. Display suite works with the rendered node (afaik), whereas AEL works with the partially-saved one. The reason why only the file id works, is because you don't need to know about anything else for an existing file when the value of your file reference field is saved.
You probably have to load the respective file yourself before you can use the filename as well.
Comment #2
milos.kroulik commentedThanks a lot, I didn't know that. I will try mentioned approach and report back.
Comment #3
bforchhammer commentedClosing issue as per #1, please re-open if there's still something to do!