Doc problem with field_attach_view

Each field is displayed according to the display options specified in the instance definition for the given view mode.

This is not correct. Instead, it should be something like "Each field is displayed according to the display options specified in the EntityDisplay object for the given field/component view mode."

see Introduced EntityDisplay config entities and
class EntityDisplay

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Thanks for reporting this!

I didn't understand your suggested wording, so I think it must need a little bit of work. :) It should probably either give some more details of the process, or link to a topic/function/class that contains those details.

smiletrl’s picture

lol...

See Introduced EntityDisplay config entities

Display options for a field are not specified in the $instance definition structure anymore.
The $instance['display'] entry no longer exists, $field and $instance definitions structures are purely about data, not about how render it.

and

Display options need to be explicitly assigned to the EntityDisplay objects :

See class EntityDisplay

    // Instantiate the formatter object from the stored display properties.
    if ($configuration = $this->getComponent($field_name)) {

So, there're no display options in instance definiton. Instead, EntityDisplay $display associated with this entity will store all attached fields' display options, that's how field_attach_view going to render each field.

jhodgdon’s picture

Title: Field is displayed according to the display options specified in the EntityDisplay object » field_attach_view() docs have some accuracy and other issues

Ah, OK. Then we can probably just say:

Each field is displayed according to the display options in the $display parameter.

Right?

Anyway, if we're in there let's fix up that whole documentation block:
- There's at least one namespace reference that does not start with a backslash (in the $entity parameter; perhaps others as well).
- What is this "sample structure" thing supposed to be? I bet that's just left over from a previous version of Drupal?
- $options says to see field_invoke_method() for details, but it doesn't mention that $options['langcode'] is set in the function and would override any value passed in.

smiletrl’s picture

Yeah, $display parameter makes it clear.

  • Well, indeed, there's some other namespace reference that does not start with a backslash, but I'd like to cover this issue here:)
  • "sample structure" is an array result returned by this function, e.g., $result = field_attach_view($entity, $displays[$entity->bundle()], $langcode); "sample structure" tells what $result looks like.
  • Add a note for 'langcode'.

Patch attaced accroding to #2.

smiletrl’s picture

Status: Active » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

If the "sample structure" is a sample return value, then it should be moved down so that it is part of the @return documentation. As it is, I couldn't figure out at a glance what it was supposed to be. I'm also not sure that we need to have a sample return value here, since it's returning a renderable array (at least according to the documentation). I'm also not sure we want to *maintain* a sample return value in this documentation. We don't do that for other functions that return renderable arrays.

So... maybe we should just get rid of that? If not, move it to @return.

Other than that, the changes look good to me, thanks!

smiletrl’s picture

Well, I guess it exists for a history reason -- D7 has this:)

Agreed it isn't put in the right place. I'm okay to get rid of it:)

smiletrl’s picture

Deleting sample return...

smiletrl’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, field_attach_view_doc-2009092-6.patch, failed testing.

smiletrl’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Whoops. I was just about to commit this but I noticed "overriden" was misspelled (should have two Ds).

smiletrl’s picture

Status: Needs work » Needs review
FileSize
677 bytes
2.33 KB

my fault:)

Status: Needs review » Needs work

The last submitted patch, field_attach_view_doc-2009092-13.patch, failed testing.

jhodgdon’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Assigned: Unassigned » jhodgdon
Status: Needs review » Reviewed & tested by the community

Thanks! I'll get this committed when it turns green.

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 8.x.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Correct the api url