Closed (fixed)
Project:
Computed Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 Jul 2011 at 20:27 UTC
Updated:
23 Sep 2012 at 15:59 UTC
hello
i am new to drupal , i wanted to created a computed field based on some values and one of them was a term reference .
i used expression like this :
$entity_field[0]['value'] = $entity->field_vendor[LANGUAGE_NONE][0]['value']
and it gave me unknown index 'value'.
i tried 'name' instead and it worked :
$entity_field[0]['value'] = $entity->field_vendor[LANGUAGE_NONE][0]['name']
i'd like to know , am i doing this right ?
p.s. i have locale enabled :)
Comments
Comment #1
abrebion commentedNone of this work for me. Any idea how I can access the value of a taxonomy field ?
Comment #2
mohscorpion commentedhave you used print_r function for debugging values ?
i found my problem using that very sweet function...
for example set the computer field to output of print_r function like this :
$entity_field[0]['value'] = print_r($entity);
or like this :
$entity_field[0]['value'] = print_r($entity->field_vendor);
when you found the language you are looking for , then go to in more details like this :
$entity_field[0]['value'] = print_r($entity->field_vendor[LANGUAGE_NONE]);
and more details :
$entity_field[0]['value'] = print_r($entity->field_vendor[LANGUAGE_NONE][0]);
this way you can debug what is going on there...
Comment #3
zualas commentedI am assuming that you wanted to get the term name based on a term reference. The system saves only the term ID in the entity object, so in order to get the term name, I am using (replace field_test_taxonomy with your field name):
$entity_field[0]['value'] = taxonomy_term_title(taxonomy_term_load($entity->field_test_taxonomy['und'][0]['tid']));Comment #4
abrebion commentedthat works perfectly, thank you very much !
Comment #5
colanComment #7
cimo75 commentedHow can i get other fields? i am doing
but it does not work.
tx
Simone