0

i am stuck retrieving an entity reference fields the correct way. All i tried gave me an error or and empty array...

What you see here is my node object that holds the data (copied from the DSM output):

... (Object) stdClass
vid (String, 2 characters ) 64
uid (String, 1 characters ) 8
type (String, 6 characters ) people
    field_people_publications (Array, 1 element) 
       und (Array, 3 elements) 
          0 (Array, 1 element)
             target_id (String, 3 characters ) 839
          1 (Array, 1 element)
             target_id (String, 3 characters ) 840
          3 (Array, 1 element)
             target_id (String, 3 characters ) 841

Documentiontion on using entity reference fields programmatically seems very very rare. I have noch found much that helped me out.

Related to the DSM output above:

How do i retrieve the entity reference field 'field_people_publications' from the node-ID #64?

What are those 'target_id' about? Inside the HTML view these are checkboxes with 5 options available. This is quite confusing.

Can you give give me a helping hand? What i wanted to do is to modify these options to some other values and save them again.

  • Could you add the code you're trying that doesn't work? Rather than explain the entirety of accessing field with an EntityMetadataWrapper, it would be much simpler to debug your specific code. Make sure you read the docs as well, they explain it pretty well – Clive Nov 18 '13 at 15:04
  • Thanks dude. I'll give it a try and will add some working/not working code here shortly. – Olli Bolli Nov 18 '13 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.