In the Field API documentation at http://api.drupal.org/api/drupal/modules--field--field.module/group/field/7 #object is not documented.
It is, however, causing errors for me, so it would be good to document what #object refers to, and whether it is mandatory or optional (i.e. if it can be removed without any adverse side-effects.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Version: 7.8 » 8.x-dev
Status: Active » Postponed (maintainer needs more info)

Um. What is #object, and where/how is it causing you problems?

Mark_L6n’s picture

Version: 8.x-dev » 7.8

I don't know what it is, it's not documented! But the Field render arrays I have examined with dpm() have it, with a value of 'stdClass'. I have tried printing them out to see what is inside but have failed so far. I was wondering if they were pointers to an enclosing object for context purposes, but that's only a wild guess.
As for the error, I am copying fields from a node to a QuickTabs tab inside that node and receiving an 'Uncaught exception thrown in session handler.' error message. Unsetting '#object' takes care of the message, but I don't know if doing this could have any bad side-effects. I'm asking about this at http://drupal.org/node/1310152

As an aside, I hope I am posting to the right place for documentation requests--I read to not post in the comments section but in the documentation issue queue. Please advise if I should post elsewhere. (Edit: I changed version # to 7.8, thinking I had made an error, but then saw you had changed it to 8. Apologies.)

jhodgdon’s picture

Oh, the field *render* arrays. That is not what is documented on the Field API page, and I don't know off-hand what they contain, or where they are documented (if anywhere actually).

And yes, this is the right place to post for documentation on api.drupal.org.

sven.lauer’s picture

Status: Postponed (maintainer needs more info) » Needs review

This actually IS documented at field_attach_view(), where a "sample structure" is given, containing:

  '#object' => the fieldable entity being displayed,

http://api.drupal.org/api/drupal/modules--field--field.attach.inc/functi...

Works as designed? Or should we link to this information from somewhere? It is not obvious for someone theming an entity etc. that this would be documented at field_attach_view() ...

jhodgdon’s picture

Status: Needs review » Active

Thanks for the detective work!

It makes sense to me that after the description of the $field and $instance arrays, we could add a line saying something like "See field_attach_view() for documentation of the render array for formatting a field." (or maybe you can come up with better wording)

sven.lauer’s picture

Status: Active » Needs review
FileSize
548 bytes

Rolling a patch based on jhodgdon's suggestion in #5 (different wording, though).

jhodgdon’s picture

Version: 7.8 » 8.x-dev
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Love it. Thanks!

Oh, this should be 8.x. Just in case, I'll push the "retest".

jhodgdon’s picture

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x and 7.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.