Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#14 | field_attach_view_doc-2009092-13.patch | 2.33 KB | smiletrl |
#14 | interdiff-8-13.txt | 677 bytes | smiletrl |
#8 | field_attach_view_doc-2009092-6.patch | 2.33 KB | smiletrl |
#8 | interdiff-4-6.txt | 1.35 KB | smiletrl |
#4 | field_attach_view_doc-2009092-3.patch | 1.46 KB | smiletrl |
Comments
Comment #1
jhodgdonThanks 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.
Comment #2
smiletrl CreditAttribution: smiletrl commentedlol...
See Introduced EntityDisplay config entities
and
See class EntityDisplay
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.
Comment #3
jhodgdonAh, 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.
Comment #4
smiletrl CreditAttribution: smiletrl commentedYeah, $display parameter makes it clear.
$result = field_attach_view($entity, $displays[$entity->bundle()], $langcode);
"sample structure" tells what $result looks like.Patch attaced accroding to #2.
Comment #5
smiletrl CreditAttribution: smiletrl commentedComment #6
jhodgdonIf 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!
Comment #7
smiletrl CreditAttribution: smiletrl commentedWell, 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:)
Comment #8
smiletrl CreditAttribution: smiletrl commentedDeleting sample return...
Comment #9
smiletrl CreditAttribution: smiletrl commentedComment #11
smiletrl CreditAttribution: smiletrl commented#8: field_attach_view_doc-2009092-6.patch queued for re-testing.
Comment #12
jhodgdonLooks good, thanks!
Comment #13
jhodgdonWhoops. I was just about to commit this but I noticed "overriden" was misspelled (should have two Ds).
Comment #14
smiletrl CreditAttribution: smiletrl commentedmy fault:)
Comment #16
jhodgdon#14: field_attach_view_doc-2009092-13.patch queued for re-testing.
Comment #17
jhodgdonThanks! I'll get this committed when it turns green.
Comment #18
jhodgdonThanks again! Committed to 8.x.
Comment #19.0
(not verified) CreditAttribution: commentedCorrect the api url